Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: use i32 type in Value #702

Merged
merged 2 commits into from
Jan 28, 2021
Merged

rust: use i32 type in Value #702

merged 2 commits into from
Jan 28, 2021

Conversation

axic
Copy link
Member

@axic axic commented Jan 28, 2021

Depends on #517.

}
pub fn as_u32(&self) -> u32 {
unsafe { self.i64 as u32 }
unsafe { self.i32 }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The confusing fact is that even though it is called i32, the type is u32 in the bindgen translated fizzy.h.

@codecov
Copy link

codecov bot commented Jan 28, 2021

Codecov Report

Merging #702 (1c10042) into master (d483edf) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #702   +/-   ##
=======================================
  Coverage   99.31%   99.31%           
=======================================
  Files          72       72           
  Lines       10628    10628           
=======================================
  Hits        10555    10555           
  Misses         73       73           
Flag Coverage Δ
spectests 90.84% <ø> (ø)
unittests 99.31% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Collaborator

@gumb0 gumb0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like no unit tests use i64 now (neither floating point types)

Consider adding tests for Value conversions.

@axic
Copy link
Member Author

axic commented Jan 28, 2021

Sure, but what test exactly? Neither Value or sys::FizzyValue is typed so not sure what is an appropriate test.

@axic
Copy link
Member Author

axic commented Jan 28, 2021

This is the kind of test we could have (this passes, at least on my CPU/FPU):

    #[test]
    fn value_conversions() {
        let v:Value = i32::MIN.into();
        assert_eq!(v.as_i32(), i32::MIN);
        assert_eq!(v.as_u32(), 2147483648);
        assert_eq!(v.as_i64(), 2147483648);
        assert_eq!(v.as_u64(), 2147483648);
        assert_eq!(v.as_f32(), -0.0);
        assert_eq!(v.as_f64(), 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010609978955);

bindings/rust/src/lib.rs Outdated Show resolved Hide resolved
@axic axic merged commit 8402a81 into master Jan 28, 2021
@axic axic deleted the rust-i32 branch January 28, 2021 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants