diff options
Diffstat (limited to 'tests/suite/foundations/float.typ')
| -rw-r--r-- | tests/suite/foundations/float.typ | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/suite/foundations/float.typ b/tests/suite/foundations/float.typ index 01769260..67d4acbf 100644 --- a/tests/suite/foundations/float.typ +++ b/tests/suite/foundations/float.typ @@ -42,6 +42,17 @@ #test(float(-calc.inf).signum(), -1.0) #test(float(float.nan).signum().is-nan(), true) +--- float-from-and-to-bytes --- +// Test float `from-bytes()` and `to-bytes()`. +#test(float.from-bytes(bytes((0, 0, 0, 0, 0, 0, 240, 63))), 1.0) +#test(float.from-bytes(bytes((63, 240, 0, 0, 0, 0, 0, 0)), endian: "big"), 1.0) +#test(1.0.to-bytes(), bytes((0, 0, 0, 0, 0, 0, 240, 63))) +#test(1.0.to-bytes(endian: "big"), bytes((63, 240, 0, 0, 0, 0, 0, 0))) + +--- float-from-bytes-bad-length --- +// Error: 2-54 bytes must have a length of exactly 8 +#float.from-bytes(bytes((0, 0, 0, 0, 0, 0, 0, 1, 0))) + --- float-repr --- // Test the `repr` function with floats. #repr(12.0) \ |
