We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 203a3db commit 706ea88Copy full SHA for 706ea88
tests/newtype.rs
@@ -34,11 +34,25 @@ fn test_from_primitive() {
34
assert_eq!(MyFloat::from_u32(25), Some(MyFloat(25.0)));
35
}
36
37
+#[test]
38
+#[cfg(has_i128)]
39
+fn test_from_primitive_128() {
40
+ assert_eq!(MyFloat::from_i128(std::i128::MIN), Some(MyFloat(-2.0.powi(127))));
41
+}
42
+
43
#[test]
44
fn test_to_primitive() {
45
assert_eq!(MyFloat(25.0).to_u32(), Some(25));
46
47
48
49
50
+fn test_to_primitive_128() {
51
+ let f = MyFloat::from_f32(std::f32::MAX).unwrap();
52
+ assert_eq!(f.to_i128(), None);
53
+ assert_eq!(f.to_u128(), Some(0xffff_ff00_0000_0000_0000_0000_0000_0000));
54
55
56
57
fn test_num_ops() {
58
assert_eq!(MyFloat(25.0) + MyFloat(10.0), MyFloat(35.0));
0 commit comments