From 43834937c7a3f99ce246ccf6da89b3d3fdd020d3 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Fri, 27 Oct 2023 21:42:55 -0700 Subject: [PATCH] initial commits --- enc/bytes/encodeuint64.go | 26 + enc/bytes/encodeuint64_test.go | 1735 ++++++++++++++++++++++++++++++++ 2 files changed, 1761 insertions(+) create mode 100644 enc/bytes/encodeuint64.go create mode 100644 enc/bytes/encodeuint64_test.go diff --git a/enc/bytes/encodeuint64.go b/enc/bytes/encodeuint64.go new file mode 100644 index 0000000..09c3ec6 --- /dev/null +++ b/enc/bytes/encodeuint64.go @@ -0,0 +1,26 @@ +package hexadecabytes + +import ( + "sourcecode.social/reiver/go-hexadeca/symbols/byte" +) + +func EncodeUint64(value uint64, symbolFunc func(byte)byte) (r15 byte, r14 byte, r13 byte, r12 byte, r11 byte, r10 byte, r9 byte, r8 byte, r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + r15, r14 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 7))), symbolFunc) + r13, r12 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 6))), symbolFunc) + r11, r10 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 5))), symbolFunc) + r9, r8 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 4))), symbolFunc) + r7, r6 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 3))), symbolFunc) + r5, r4 = EncodeByte(byte(0x00000000000000ff & (value >> (8 * 2))), symbolFunc) + r3, r2 = EncodeByte(byte(0x00000000000000ff & (value >> (8 ))), symbolFunc) + r1, r0 = EncodeByte(byte(0x00000000000000ff & value ), symbolFunc) + + return +} + +func EncodeUint64UsingLowerCaseSymbols(value uint64) (r15 byte, r14 byte, r13 byte, r12 byte, r11 byte, r10 byte, r9 byte, r8 byte, r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeUint64(value, bytesymbols.LowerCase) +} + +func EncodeUint64UsingUpperCaseSymbols(value uint64) (r15 byte, r14 byte, r13 byte, r12 byte, r11 byte, r10 byte, r9 byte, r8 byte, r7 byte, r6 byte, r5 byte, r4 byte, r3 byte, r2 byte, r1 byte, r0 byte) { + return EncodeUint64(value, bytesymbols.UpperCase) +} diff --git a/enc/bytes/encodeuint64_test.go b/enc/bytes/encodeuint64_test.go new file mode 100644 index 0000000..8a979f6 --- /dev/null +++ b/enc/bytes/encodeuint64_test.go @@ -0,0 +1,1735 @@ +package hexadecabytes_test + +import ( + "testing" + + "sourcecode.social/reiver/go-hexadeca/enc/bytes" +) + +func TestEncodeUint64UsingLowerCaseSymbols(t *testing.T) { + + tests := []struct{ + Value uint64 + Expected15 byte + Expected14 byte + Expected13 byte + Expected12 byte + Expected11 byte + Expected10 byte + Expected9 byte + Expected8 byte + Expected7 byte + Expected6 byte + Expected5 byte + Expected4 byte + Expected3 byte + Expected2 byte + Expected1 byte + Expected0 byte + }{ + { + Value: 0x0000000000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + { + Value: 0x0000000000000001, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '1', + }, + { + Value: 0x0000000000000002, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '2', + }, + { + Value: 0x0000000000000003, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '3', + }, + { + Value: 0x0000000000000004, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '4', + }, + { + Value: 0x0000000000000005, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '5', + }, + { + Value: 0x0000000000000006, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '6', + }, + { + Value: 0x0000000000000007, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '7', + }, + { + Value: 0x0000000000000008, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '8', + }, + { + Value: 0x0000000000000009, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '9', + }, + { + Value: 0x000000000000000A, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'a', + }, + { + Value: 0x000000000000000B, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'b', + }, + { + Value: 0x000000000000000C, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'c', + }, + { + Value: 0x000000000000000D, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'd', + }, + { + Value: 0x000000000000000E, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'e', + }, + { + Value: 0x000000000000000F, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'f', + }, + { + Value: 0x0000000000000010, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '1', + Expected0: '0', + }, + + + + { + Value: 0x0000000000000100, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '1', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000000001000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '1', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000000010000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '1', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000000100000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '1', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000001000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '1', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000010000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '1', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000100000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '1', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000001000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '1', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000010000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '1', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000100000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '1', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0001000000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '1', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0010000000000000, + Expected15: '0', + Expected14: '0', + Expected13: '1', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0100000000000000, + Expected15: '0', + Expected14: '1', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x1000000000000000, + Expected15: '1', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0xDEADC0DE00000000, + Expected15: 'd', + Expected14: 'e', + Expected13: 'a', + Expected12: 'd', + Expected11: 'c', + Expected10: '0', + Expected9: 'd', + Expected8: 'e', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0xFEDCBA9876543210, + Expected15: 'f', + Expected14: 'e', + Expected13: 'd', + Expected12: 'c', + Expected11: 'b', + Expected10: 'a', + Expected9: '9', + Expected8: '8', + Expected7: '7', + Expected6: '6', + Expected5: '5', + Expected4: '4', + Expected3: '3', + Expected2: '2', + Expected1: '1', + Expected0: '0', + }, + + + + { + Value: 0xFFFFFFFFFFFFFFF9, + Expected15: 'f', + Expected14: 'f', + Expected13: 'f', + Expected12: 'f', + Expected11: 'f', + Expected10: 'f', + Expected9: 'f', + Expected8: 'f', + Expected7: 'f', + Expected6: 'f', + Expected5: 'f', + Expected4: 'f', + Expected3: 'f', + Expected2: 'f', + Expected1: 'f', + Expected0: '9', + }, + { + Value: 0xFFFFFFFFFFFFFFFA, + Expected15: 'f', + Expected14: 'f', + Expected13: 'f', + Expected12: 'f', + Expected11: 'f', + Expected10: 'f', + Expected9: 'f', + Expected8: 'f', + Expected7: 'f', + Expected6: 'f', + Expected5: 'f', + Expected4: 'f', + Expected3: 'f', + Expected2: 'f', + Expected1: 'f', + Expected0: 'a', + }, + { + Value: 0xFFFFFFFFFFFFFFFB, + Expected15: 'f', + Expected14: 'f', + Expected13: 'f', + Expected12: 'f', + Expected11: 'f', + Expected10: 'f', + Expected9: 'f', + Expected8: 'f', + Expected7: 'f', + Expected6: 'f', + Expected5: 'f', + Expected4: 'f', + Expected3: 'f', + Expected2: 'f', + Expected1: 'f', + Expected0: 'b', + }, + { + Value: 0xFFFFFFFFFFFFFFFC, + Expected15: 'f', + Expected14: 'f', + Expected13: 'f', + Expected12: 'f', + Expected11: 'f', + Expected10: 'f', + Expected9: 'f', + Expected8: 'f', + Expected7: 'f', + Expected6: 'f', + Expected5: 'f', + Expected4: 'f', + Expected3: 'f', + Expected2: 'f', + Expected1: 'f', + Expected0: 'c', + }, + { + Value: 0xFFFFFFFFFFFFFFFD, + Expected15: 'f', + Expected14: 'f', + Expected13: 'f', + Expected12: 'f', + Expected11: 'f', + Expected10: 'f', + Expected9: 'f', + Expected8: 'f', + Expected7: 'f', + Expected6: 'f', + Expected5: 'f', + Expected4: 'f', + Expected3: 'f', + Expected2: 'f', + Expected1: 'f', + Expected0: 'd', + }, + { + Value: 0xFFFFFFFFFFFFFFFE, + Expected15: 'f', + Expected14: 'f', + Expected13: 'f', + Expected12: 'f', + Expected11: 'f', + Expected10: 'f', + Expected9: 'f', + Expected8: 'f', + Expected7: 'f', + Expected6: 'f', + Expected5: 'f', + Expected4: 'f', + Expected3: 'f', + Expected2: 'f', + Expected1: 'f', + Expected0: 'e', + }, + { + Value: 0xFFFFFFFFFFFFFFFF, + Expected15: 'f', + Expected14: 'f', + Expected13: 'f', + Expected12: 'f', + Expected11: 'f', + Expected10: 'f', + Expected9: 'f', + Expected8: 'f', + Expected7: 'f', + Expected6: 'f', + Expected5: 'f', + Expected4: 'f', + Expected3: 'f', + Expected2: 'f', + Expected1: 'f', + Expected0: 'f', + }, + } + + for testNumber, test := range tests { + + actual15, actual14, actual13, actual12, actual11, actual10, actual9, actual8, actual7, actual6, actual5, actual4, actual3, actual2, actual1, actual0 := hexadecabytes.EncodeUint64UsingLowerCaseSymbols(test.Value) + expected15, expected14, expected13, expected12, expected11, expected10, expected9, expected8, expected7, expected6, expected5, expected4, expected3, expected2, expected1, expected0 := test.Expected15, test.Expected14, test.Expected13, test.Expected12, test.Expected11, test.Expected10, test.Expected9, test.Expected8, test.Expected7, test.Expected6, test.Expected5, test.Expected4, test.Expected3, test.Expected2, test.Expected1, test.Expected0 + + if expected15 != actual15 || + expected14 != actual14 || + expected13 != actual13 || + expected12 != actual12 || + expected11 != actual11 || + expected10 != actual10 || + expected9 != actual9 || + expected8 != actual8 || + expected7 != actual7 || + expected6 != actual6 || + expected5 != actual5 || + expected4 != actual4 || + expected3 != actual3 || + expected2 != actual2 || + expected1 != actual1 || + expected0 != actual0 { + t.Errorf("For test #%d, the actual values is not what was expected.", testNumber) + t.Logf("EXPECTED: (%q %q %q %q %q %q %q %q %q %q %q %q %q %q %q %q)", expected15, expected14, expected13, expected12, expected11, expected10, expected9, expected8, expected7, expected6, expected5, expected4, expected3, expected2, expected1, expected0) + t.Logf("ACTUAL: (%q %q %q %q %q %q %q %q %q %q %q %q %q %q %q %q)", actual15, actual14, actual13, actual12, actual11, actual10, actual9, actual8, actual7, actual6, actual5, actual4, actual3, actual2, actual1, actual0) + t.Logf("VALUE: 0x%X", test.Value) + continue + } + } +} + +func TestEncodeUint64UsingUpperCaseSymbols(t *testing.T) { + + tests := []struct{ + Value uint64 + Expected15 byte + Expected14 byte + Expected13 byte + Expected12 byte + Expected11 byte + Expected10 byte + Expected9 byte + Expected8 byte + Expected7 byte + Expected6 byte + Expected5 byte + Expected4 byte + Expected3 byte + Expected2 byte + Expected1 byte + Expected0 byte + }{ + { + Value: 0x0000000000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + { + Value: 0x0000000000000001, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '1', + }, + { + Value: 0x0000000000000002, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '2', + }, + { + Value: 0x0000000000000003, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '3', + }, + { + Value: 0x0000000000000004, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '4', + }, + { + Value: 0x0000000000000005, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '5', + }, + { + Value: 0x0000000000000006, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '6', + }, + { + Value: 0x0000000000000007, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '7', + }, + { + Value: 0x0000000000000008, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '8', + }, + { + Value: 0x0000000000000009, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '9', + }, + { + Value: 0x000000000000000A, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'A', + }, + { + Value: 0x000000000000000B, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'B', + }, + { + Value: 0x000000000000000C, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'C', + }, + { + Value: 0x000000000000000D, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'D', + }, + { + Value: 0x000000000000000E, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'E', + }, + { + Value: 0x000000000000000F, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: 'F', + }, + { + Value: 0x0000000000000010, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '1', + Expected0: '0', + }, + + + + { + Value: 0x0000000000000100, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '1', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000000001000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '1', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000000010000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '1', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000000100000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '1', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000001000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '1', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000010000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '1', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000000100000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '1', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000001000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '1', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000010000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '1', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0000100000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '1', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0001000000000000, + Expected15: '0', + Expected14: '0', + Expected13: '0', + Expected12: '1', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0010000000000000, + Expected15: '0', + Expected14: '0', + Expected13: '1', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x0100000000000000, + Expected15: '0', + Expected14: '1', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0x1000000000000000, + Expected15: '1', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0xDEADC0DE00000000, + Expected15: 'D', + Expected14: 'E', + Expected13: 'A', + Expected12: 'D', + Expected11: 'C', + Expected10: '0', + Expected9: 'D', + Expected8: 'E', + Expected7: '0', + Expected6: '0', + Expected5: '0', + Expected4: '0', + Expected3: '0', + Expected2: '0', + Expected1: '0', + Expected0: '0', + }, + + + + { + Value: 0xFEDCBA9876543210, + Expected15: 'F', + Expected14: 'E', + Expected13: 'D', + Expected12: 'C', + Expected11: 'B', + Expected10: 'A', + Expected9: '9', + Expected8: '8', + Expected7: '7', + Expected6: '6', + Expected5: '5', + Expected4: '4', + Expected3: '3', + Expected2: '2', + Expected1: '1', + Expected0: '0', + }, + + + + { + Value: 0xFFFFFFFFFFFFFFF9, + Expected15: 'F', + Expected14: 'F', + Expected13: 'F', + Expected12: 'F', + Expected11: 'F', + Expected10: 'F', + Expected9: 'F', + Expected8: 'F', + Expected7: 'F', + Expected6: 'F', + Expected5: 'F', + Expected4: 'F', + Expected3: 'F', + Expected2: 'F', + Expected1: 'F', + Expected0: '9', + }, + { + Value: 0xFFFFFFFFFFFFFFFA, + Expected15: 'F', + Expected14: 'F', + Expected13: 'F', + Expected12: 'F', + Expected11: 'F', + Expected10: 'F', + Expected9: 'F', + Expected8: 'F', + Expected7: 'F', + Expected6: 'F', + Expected5: 'F', + Expected4: 'F', + Expected3: 'F', + Expected2: 'F', + Expected1: 'F', + Expected0: 'A', + }, + { + Value: 0xFFFFFFFFFFFFFFFB, + Expected15: 'F', + Expected14: 'F', + Expected13: 'F', + Expected12: 'F', + Expected11: 'F', + Expected10: 'F', + Expected9: 'F', + Expected8: 'F', + Expected7: 'F', + Expected6: 'F', + Expected5: 'F', + Expected4: 'F', + Expected3: 'F', + Expected2: 'F', + Expected1: 'F', + Expected0: 'B', + }, + { + Value: 0xFFFFFFFFFFFFFFFC, + Expected15: 'F', + Expected14: 'F', + Expected13: 'F', + Expected12: 'F', + Expected11: 'F', + Expected10: 'F', + Expected9: 'F', + Expected8: 'F', + Expected7: 'F', + Expected6: 'F', + Expected5: 'F', + Expected4: 'F', + Expected3: 'F', + Expected2: 'F', + Expected1: 'F', + Expected0: 'C', + }, + { + Value: 0xFFFFFFFFFFFFFFFD, + Expected15: 'F', + Expected14: 'F', + Expected13: 'F', + Expected12: 'F', + Expected11: 'F', + Expected10: 'F', + Expected9: 'F', + Expected8: 'F', + Expected7: 'F', + Expected6: 'F', + Expected5: 'F', + Expected4: 'F', + Expected3: 'F', + Expected2: 'F', + Expected1: 'F', + Expected0: 'D', + }, + { + Value: 0xFFFFFFFFFFFFFFFE, + Expected15: 'F', + Expected14: 'F', + Expected13: 'F', + Expected12: 'F', + Expected11: 'F', + Expected10: 'F', + Expected9: 'F', + Expected8: 'F', + Expected7: 'F', + Expected6: 'F', + Expected5: 'F', + Expected4: 'F', + Expected3: 'F', + Expected2: 'F', + Expected1: 'F', + Expected0: 'E', + }, + { + Value: 0xFFFFFFFFFFFFFFFF, + Expected15: 'F', + Expected14: 'F', + Expected13: 'F', + Expected12: 'F', + Expected11: 'F', + Expected10: 'F', + Expected9: 'F', + Expected8: 'F', + Expected7: 'F', + Expected6: 'F', + Expected5: 'F', + Expected4: 'F', + Expected3: 'F', + Expected2: 'F', + Expected1: 'F', + Expected0: 'F', + }, + } + + for testNumber, test := range tests { + + actual15, actual14, actual13, actual12, actual11, actual10, actual9, actual8, actual7, actual6, actual5, actual4, actual3, actual2, actual1, actual0 := hexadecabytes.EncodeUint64UsingUpperCaseSymbols(test.Value) + expected15, expected14, expected13, expected12, expected11, expected10, expected9, expected8, expected7, expected6, expected5, expected4, expected3, expected2, expected1, expected0 := test.Expected15, test.Expected14, test.Expected13, test.Expected12, test.Expected11, test.Expected10, test.Expected9, test.Expected8, test.Expected7, test.Expected6, test.Expected5, test.Expected4, test.Expected3, test.Expected2, test.Expected1, test.Expected0 + + if expected15 != actual15 || + expected14 != actual14 || + expected13 != actual13 || + expected12 != actual12 || + expected11 != actual11 || + expected10 != actual10 || + expected9 != actual9 || + expected8 != actual8 || + expected7 != actual7 || + expected6 != actual6 || + expected5 != actual5 || + expected4 != actual4 || + expected3 != actual3 || + expected2 != actual2 || + expected1 != actual1 || + expected0 != actual0 { + t.Errorf("For test #%d, the actual values is not what was expected.", testNumber) + t.Logf("EXPECTED: (%q %q %q %q %q %q %q %q %q %q %q %q %q %q %q %q)", expected15, expected14, expected13, expected12, expected11, expected10, expected9, expected8, expected7, expected6, expected5, expected4, expected3, expected2, expected1, expected0) + t.Logf("ACTUAL: (%q %q %q %q %q %q %q %q %q %q %q %q %q %q %q %q)", actual15, actual14, actual13, actual12, actual11, actual10, actual9, actual8, actual7, actual6, actual5, actual4, actual3, actual2, actual1, actual0) + t.Logf("VALUE: 0x%X", test.Value) + continue + } + } +}