| 66 | } |
| 67 | |
| 68 | func TestConsistency(t *testing.T) { |
| 69 | hash1 := New(1, nil) |
| 70 | hash2 := New(1, nil) |
| 71 | |
| 72 | hash1.Add("Bill", "Bob", "Bonny") |
| 73 | hash2.Add("Bob", "Bonny", "Bill") |
| 74 | |
| 75 | if hash1.Get("Ben") != hash2.Get("Ben") { |
| 76 | t.Errorf("Fetching 'Ben' from both hashes should be the same") |
| 77 | } |
| 78 | |
| 79 | hash2.Add("Becky", "Ben", "Bobby") |
| 80 | |
| 81 | if hash1.Get("Ben") != hash2.Get("Ben") || |
| 82 | hash1.Get("Bob") != hash2.Get("Bob") || |
| 83 | hash1.Get("Bonny") != hash2.Get("Bonny") { |
| 84 | t.Errorf("Direct matches should always return the same entry") |
| 85 | } |
| 86 | |
| 87 | } |
| 88 | |
| 89 | func BenchmarkGet8(b *testing.B) { benchmarkGet(b, 8) } |
| 90 | func BenchmarkGet32(b *testing.B) { benchmarkGet(b, 32) } |