authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-23 08:25:26-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2018-08-23 08:25:26-04:00
log68dcdf1c867a918aa0bb7b5c4cb42df185e1c8f9
tree6bac6ca779a392c5fec4dcf29f18608763d6ddab
parent4b68ef45af54abd7ba56878f93132ca608891cf1
parente95345b3dce204c4c463294b3dfdb09f9f6d9795
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #1401 from kristate/mem-testWriteIntImpl-u64

std/mem.zig: test writing u64 integers;

1 files changed, 41 insertions(+), 1 deletions(-)

std/mem.zig+41-1
......@@ -679,10 +679,38 @@ test "testWriteInt" {
679679 comptime testWriteIntImpl();
680680}
681681fn testWriteIntImpl() void {
682 var bytes: [4]u8 = undefined;
682 var bytes: [8]u8 = undefined;
683
684 writeInt(bytes[0..], u64(0x12345678CAFEBABE), builtin.Endian.Big);
685 assert(eql(u8, bytes, []u8{
686 0x12,
687 0x34,
688 0x56,
689 0x78,
690 0xCA,
691 0xFE,
692 0xBA,
693 0xBE,
694 }));
695
696 writeInt(bytes[0..], u64(0xBEBAFECA78563412), builtin.Endian.Little);
697 assert(eql(u8, bytes, []u8{
698 0x12,
699 0x34,
700 0x56,
701 0x78,
702 0xCA,
703 0xFE,
704 0xBA,
705 0xBE,
706 }));
683707
684708 writeInt(bytes[0..], u32(0x12345678), builtin.Endian.Big);
685709 assert(eql(u8, bytes, []u8{
710 0x00,
711 0x00,
712 0x00,
713 0x00,
686714 0x12,
687715 0x34,
688716 0x56,
......@@ -695,10 +723,18 @@ fn testWriteIntImpl() void {
695723 0x34,
696724 0x56,
697725 0x78,
726 0x00,
727 0x00,
728 0x00,
729 0x00,
698730 }));
699731
700732 writeInt(bytes[0..], u16(0x1234), builtin.Endian.Big);
701733 assert(eql(u8, bytes, []u8{
734 0x00,
735 0x00,
736 0x00,
737 0x00,
702738 0x00,
703739 0x00,
704740 0x12,
......@@ -711,6 +747,10 @@ fn testWriteIntImpl() void {
711747 0x12,
712748 0x00,
713749 0x00,
750 0x00,
751 0x00,
752 0x00,
753 0x00,
714754 }));
715755}
716756