diff options
| author | Tim Voßhenrich <94936637+T1mVo@users.noreply.github.com> | 2024-09-26 11:14:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-26 09:14:45 +0000 |
| commit | 5823429a968eeb60f39aba55302f4fca57bdf615 (patch) | |
| tree | 7444e64055844d083275c5bb2de33c6d053452cb /tests | |
| parent | 4827f28a940b9610e55afb888ddde11e240caa20 (diff) | |
Add float to bytes conversion and vice-versa (#4989)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
| -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) \ |
