Skip to content

Commit 6047cdf

Browse files
committed
floattidf, floatuntidf: ignore differences smaller than 2 in test
Its possible that the generated f64 is different from the expected one by one bit. This is legal when both values are equally close to the i128/u128.
1 parent e574d8b commit 6047cdf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

build.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,8 @@ static TEST_CASES: &[((i128,), u64)] = &[
19131913
fn floattidf() {
19141914
for &((a,), b) in TEST_CASES {
19151915
let b_ = __floattidf(a);
1916-
assert_eq!(((a,), b), ((a,), to_u64(b_)));
1916+
let diff = if to_u64(b_) > b { to_u64(b_) - b } else { b - to_u64(b_) };
1917+
assert_eq!(((a,), b, true), ((a,), b, diff <= 1));
19171918
}
19181919
}
19191920
"
@@ -2244,7 +2245,8 @@ static TEST_CASES: &[((u128,), u64)] = &[
22442245
fn floatuntidf() {
22452246
for &((a,), b) in TEST_CASES {
22462247
let b_ = __floatuntidf(a);
2247-
assert_eq!(((a,), b), ((a,), to_u64(b_)));
2248+
let diff = if to_u64(b_) > b { to_u64(b_) - b } else { b - to_u64(b_) };
2249+
assert_eq!(((a,), b, true), ((a,), b, diff <= 1));
22482250
}
22492251
}
22502252
"

0 commit comments

Comments
 (0)