| 5 | ) |
| 6 | |
| 7 | func TestLinear(t *testing.T) { |
| 8 | for _, test := range searchTests { |
| 9 | actualValue, actualError := Linear(test.data, test.key) |
| 10 | if actualValue != test.expected { |
| 11 | t.Errorf("test '%s' failed: input array '%v' with key '%d', expected '%d', get '%d'", test.name, test.data, test.key, test.expected, actualValue) |
| 12 | } |
| 13 | if actualError != test.expectedError { |
| 14 | t.Errorf("test '%s' failed: input array '%v' with key '%d', expected error '%s', get error '%s'", test.name, test.data, test.key, test.expectedError, actualError) |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | func BenchmarkLinear(b *testing.B) { |
| 20 | testCase := generateBenchmarkTestCase() |