| ... | ... | @@ -679,10 +679,38 @@ test "testWriteInt" { |
| 679 | 679 | comptime testWriteIntImpl(); |
| 680 | 680 | } |
| 681 | 681 | fn 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 | })); |
| 683 | 707 | |
| 684 | 708 | writeInt(bytes[0..], u32(0x12345678), builtin.Endian.Big); |
| 685 | 709 | assert(eql(u8, bytes, []u8{ |
| 710 | 0x00, |
| 711 | 0x00, |
| 712 | 0x00, |
| 713 | 0x00, |
| 686 | 714 | 0x12, |
| 687 | 715 | 0x34, |
| 688 | 716 | 0x56, |
| ... | ... | @@ -695,10 +723,18 @@ fn testWriteIntImpl() void { |
| 695 | 723 | 0x34, |
| 696 | 724 | 0x56, |
| 697 | 725 | 0x78, |
| 726 | 0x00, |
| 727 | 0x00, |
| 728 | 0x00, |
| 729 | 0x00, |
| 698 | 730 | })); |
| 699 | 731 | |
| 700 | 732 | writeInt(bytes[0..], u16(0x1234), builtin.Endian.Big); |
| 701 | 733 | assert(eql(u8, bytes, []u8{ |
| 734 | 0x00, |
| 735 | 0x00, |
| 736 | 0x00, |
| 737 | 0x00, |
| 702 | 738 | 0x00, |
| 703 | 739 | 0x00, |
| 704 | 740 | 0x12, |
| ... | ... | @@ -711,6 +747,10 @@ fn testWriteIntImpl() void { |
| 711 | 747 | 0x12, |
| 712 | 748 | 0x00, |
| 713 | 749 | 0x00, |
| 750 | 0x00, |
| 751 | 0x00, |
| 752 | 0x00, |
| 753 | 0x00, |
| 714 | 754 | })); |
| 715 | 755 | } |
| 716 | 756 | |