Files
mercury/tests/hard_coded/int64_from_bytes.m
Julien Fischer da8d80d6bc Implement from_bytes_{le,be} for 64-bit integers.
library/int64.m:
library/uint64.m:
    As above.

tests/hard_coded/Mmakefile:
tests/hard_coded/{int6,uint64}_from-bytes.{m,exp}:
    Add tests of the new functions.
2018-02-08 01:04:17 -05:00

46 lines
2.2 KiB
Mathematica

:- module int64_from_bytes.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int64.
main(!IO) :-
Test1 = int64.from_bytes_le(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8),
io.write_line(Test1, !IO),
Test2 = int64.from_bytes_le(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8),
io.write_line(Test2, !IO),
Test3 = int64.from_bytes_le(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8),
io.write_line(Test3, !IO),
Test4 = int64.from_bytes_le(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test4, !IO),
Test5 = int64.from_bytes_le(0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test5, !IO),
Test6 = int64.from_bytes_le(0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test6, !IO),
Test7 = int64.from_bytes_le(0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test7, !IO),
Test8 = int64.from_bytes_le(0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test8, !IO),
Test9 = int64.from_bytes_be(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8),
io.write_line(Test9, !IO),
Test10 = int64.from_bytes_be(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8),
io.write_line(Test10, !IO),
Test11 = int64.from_bytes_be(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8),
io.write_line(Test11, !IO),
Test12 = int64.from_bytes_be(0x00u8, 0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test12, !IO),
Test13 = int64.from_bytes_be(0x00u8, 0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test13, !IO),
Test14 = int64.from_bytes_be(0x00u8, 0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test14, !IO),
Test15 = int64.from_bytes_be(0x00u8, 0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test15, !IO),
Test16 = int64.from_bytes_be(0xffu8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8),
io.write_line(Test16, !IO).