From 8350e8a39f947d91ae4219044ebe9f4cd026dd5f Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Fri, 27 Oct 2023 00:58:13 -0700 Subject: [PATCH] initial commits --- encodeint64.go | 26 + encodeint64_test.go | 1735 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1761 insertions(+) create mode 100644 encodeint64.go create mode 100644 encodeint64_test.go diff --git a/encodeint64.go b/encodeint64.go new file mode 100644 index 0000000..91a5b9b --- /dev/null +++ b/encodeint64.go @@ -0,0 +1,26 @@ +package hexadeca + +func EncodeInt64(value int64, symbolFunc func(byte)rune) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + 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 EncodeInt64UsingLowerCaseSymbols(value int64) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt64(value, SymbolLowerCase) +} + +func EncodeInt64UsingPersianSymbols(value int64) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt64(value, SymbolPersian) +} + +func EncodeInt64UsingUpperCaseSymbols(value int64) (r15 rune, r14 rune, r13 rune, r12 rune, r11 rune, r10 rune, r9 rune, r8 rune, r7 rune, r6 rune, r5 rune, r4 rune, r3 rune, r2 rune, r1 rune, r0 rune) { + return EncodeInt64(value, SymbolUpperCase) +} diff --git a/encodeint64_test.go b/encodeint64_test.go new file mode 100644 index 0000000..b97e1ab --- /dev/null +++ b/encodeint64_test.go @@ -0,0 +1,1735 @@ +package hexadeca_test + +import ( + "testing" + + "sourcecode.social/reiver/go-hexadeca" +) + +func TestEncodeInt64UsingLowerCaseSymbols(t *testing.T) { + + tests := []struct{ + Value int64 + Expected15 rune + Expected14 rune + Expected13 rune + Expected12 rune + Expected11 rune + Expected10 rune + Expected9 rune + Expected8 rune + Expected7 rune + Expected6 rune + Expected5 rune + Expected4 rune + Expected3 rune + Expected2 rune + Expected1 rune + Expected0 rune + }{ + { + 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: 0x70000000DEADC0DE, + Expected15: '7', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: 'd', + Expected6: 'e', + Expected5: 'a', + Expected4: 'd', + Expected3: 'c', + Expected2: '0', + Expected1: 'd', + Expected0: 'e', + }, + + + + { + Value: 0x7EDCBA98F6543210, + Expected15: '7', + Expected14: 'e', + Expected13: 'd', + Expected12: 'c', + Expected11: 'b', + Expected10: 'a', + Expected9: '9', + Expected8: '8', + Expected7: 'f', + Expected6: '6', + Expected5: '5', + Expected4: '4', + Expected3: '3', + Expected2: '2', + Expected1: '1', + Expected0: '0', + }, + + + + { + Value: 0x7FFFFFFFFFFFFFF9, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFA, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFB, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFC, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFD, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFE, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFF, + Expected15: '7', + 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 := hexadeca.EncodeInt64UsingLowerCaseSymbols(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 TestEncodeInt64UsingUpperCaseSymbols(t *testing.T) { + + tests := []struct{ + Value int64 + Expected15 rune + Expected14 rune + Expected13 rune + Expected12 rune + Expected11 rune + Expected10 rune + Expected9 rune + Expected8 rune + Expected7 rune + Expected6 rune + Expected5 rune + Expected4 rune + Expected3 rune + Expected2 rune + Expected1 rune + Expected0 rune + }{ + { + 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: 0x70000000DEADC0DE, + Expected15: '7', + Expected14: '0', + Expected13: '0', + Expected12: '0', + Expected11: '0', + Expected10: '0', + Expected9: '0', + Expected8: '0', + Expected7: 'D', + Expected6: 'E', + Expected5: 'A', + Expected4: 'D', + Expected3: 'C', + Expected2: '0', + Expected1: 'D', + Expected0: 'E', + }, + + + + { + Value: 0x7EDCBA98F6543210, + Expected15: '7', + Expected14: 'E', + Expected13: 'D', + Expected12: 'C', + Expected11: 'B', + Expected10: 'A', + Expected9: '9', + Expected8: '8', + Expected7: 'F', + Expected6: '6', + Expected5: '5', + Expected4: '4', + Expected3: '3', + Expected2: '2', + Expected1: '1', + Expected0: '0', + }, + + + + { + Value: 0x7FFFFFFFFFFFFFF9, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFA, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFB, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFC, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFD, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFE, + Expected15: '7', + 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: 0x7FFFFFFFFFFFFFFF, + Expected15: '7', + 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 := hexadeca.EncodeInt64UsingUpperCaseSymbols(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 + } + } +}