MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestDoubleHashFuncs

Function TestDoubleHashFuncs

crypto/hash/hashfuncs_test.go:91–151  ·  view source on GitHub ↗

TestDoubleHashFuncs ensures the hash functions which perform hash(hash(b)) work as expected.

(t *testing.T)

Source from the content-addressed store, hash-verified

89// TestDoubleHashFuncs ensures the hash functions which perform hash(hash(b))
90// work as expected.
91func TestDoubleHashFuncs(t *testing.T) {
92 tests := []struct {
93 out string
94 in string
95 }{
96 {"5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456", ""},
97 {"bf5d3affb73efd2ec6c36ad3112dd933efed63c4e1cbffcfa88e2759c144f2d8", "a"},
98 {"a1ff8f1856b5e24e32e3882edd4a021f48f28a8b21854b77fdef25a97601aace", "ab"},
99 {"4f8b42c22dd3729b519ba6f68d2da7cc5b2d606d05daed5ad5128cc03e6c6358", "abc"},
100 {"7e9c158ecd919fa439a7a214c9fc58b85c3177fb1613bdae41ee695060e11bc6", "abcd"},
101 {"1d72b6eb7ba8b9709c790b33b40d8c46211958e13cf85dbcda0ed201a99f2fb9", "abcde"},
102 {"ce65d4756128f0035cba4d8d7fae4e9fa93cf7fdf12c0f83ee4a0e84064bef8a", "abcdef"},
103 {"dad6b965ad86b880ceb6993f98ebeeb242de39f6b87a458c6510b5a15ff7bbf1", "abcdefg"},
104 {"b9b12e7125f73fda20b8c4161fb9b4b146c34cf88595a1e0503ca2cf44c86bc4", "abcdefgh"},
105 {"546db09160636e98405fbec8464a84b6464b32514db259e235eae0445346ffb7", "abcdefghi"},
106 {"27635cf23fdf8a10f4cb2c52ade13038c38718c6d7ca716bfe726111a57ad201", "abcdefghij"},
107 {"ae0d8e0e7c0336f0c3a72cefa4f24b625a6a460417a921d066058a0b81e23429", "Discard medicine more than two years old."},
108 {"eeb56d02cf638f87ea8f11ebd5b0201afcece984d87be458578d3cfb51978f1b", "He who has a shady past knows that nice guys finish last."},
109 {"dc640bf529608a381ea7065ecbcd0443b95f6e4c008de6e134aff1d36bd4b9d8", "I wouldn't marry him with a ten foot pole."},
110 {"42e54375e60535eb07fc15c6350e10f2c22526f84db1d6f6bba925e154486f33", "Free! Free!/A trip/to Mars/for 900/empty jars/Burma Shave"},
111 {"4ed6aa9b88c84afbf928710b03714de69e2ad967c6a78586069adcb4c470d150", "The days of the digital watch are numbered. -Tom Stoppard"},
112 {"590c24d1877c1919fad12fe01a8796999e9d20cfbf9bc9bc72fa0bd69f0b04dd", "Nepal premier won't resign."},
113 {"37d270687ee8ebafcd3c1a32f56e1e1304b3c93f252cb637d57a66d59c475eca", "For every action there is an equal and opposite government program."},
114 {"306828fd89278838bb1c544c3032a1fd25ea65c40bba586437568828a5fbe944", "His money is twice tainted: 'taint yours and 'taint mine."},
115 {"49965777eac71faf1e2fb0f6b239ba2fae770977940fd827bcbfe15def6ded53", "There is no reason for any individual to have a computer in their home. -Ken Olsen, 1977"},
116 {"df99ee4e87dd3fb07922dee7735997bbae8f26db20c86137d4219fc4a37b77c3", "It's a tiny change to the code and not completely disgusting. - Bob Manchek"},
117 {"920667c84a15b5ee3df4620169f5c0ec930cea0c580858e50e68848871ed65b4", "size: a.out: bad magic"},
118 {"5e817fe20848a4a3932db68e90f8d54ec1b09603f0c99fdc051892b776acd462", "The major problem is with sendmail. -Mark Horton"},
119 {"6a9d47248ed38852f5f4b2e37e7dfad0ce8d1da86b280feef94ef267e468cff2", "Give me a rock, paper and scissors and I will move the world. CCFestoon"},
120 {"2e7aa1b362c94efdbff582a8bd3f7f61c8ce4c25bbde658ef1a7ae1010e2126f", "If the enemy is within range, then so are you."},
121 {"e6729d51240b1e1da76d822fd0c55c75e409bcb525674af21acae1f11667c8ca", "It's well we cannot hear the screams/That we create in others' dreams."},
122 {"09945e4d2743eb669f85e4097aa1cc39ea680a0b2ae2a65a42a5742b3b809610", "You remind me of a TV show, but that's all right: I watch it anyway."},
123 {"1018d8b2870a974887c5174360f0fbaf27958eef15b24522a605c5dae4ae0845", "C is as portable as Stonehedge!!"},
124 {"97c76b83c6645c78c261dcdc55d44af02d9f1df8057f997fd08c310c903624d5", "Even if I could be Shakespeare, I think I should still choose to be Faraday. - A. Huxley"},
125 {"6bcbf25469e9544c5b5806b24220554fedb6695ba9b1510a76837414f7adb113", "The fugacity of a constituent in a mixture of gases at a given temperature is proportional to its mole fraction. Lewis-Randall Rule"},
126 {"1041988b06835481f0845be2a54f4628e1da26145b2de7ad1be3bb643cef9d4f", "How can you write a big system without C++? -Paul Glick"},
127 }
128
129 // Ensure the hash function which returns a byte slice returns the
130 // expected result.
131 for _, test := range tests {
132 h := fmt.Sprintf("%x", DoubleHashB([]byte(test.in)))
133 if h != test.out {
134 t.Errorf("DoubleHashB(%q) = %s, want %s", test.in, h,
135 test.out)
136 continue
137 }
138 }
139
140 // Ensure the hash function which returns a Hash returns the expected
141 // result.
142 for _, test := range tests {
143 hash := DoubleHashH([]byte(test.in))
144 h := fmt.Sprintf("%x", hash[:])
145 if h != test.out {
146 t.Errorf("DoubleHashH(%q) = %s, want %s", test.in, h,
147 test.out)
148 continue

Callers

nothing calls this directly

Calls 3

DoubleHashBFunction · 0.85
DoubleHashHFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected