MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestBinary

Function TestBinary

search/binary_test.go:8–18  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestBinary(t *testing.T) {
9 for _, test := range searchTests {
10 actualValue, actualError := Binary(test.data, test.key, 0, len(test.data)-1)
11 if actualValue != test.expected {
12 t.Errorf("test '%s' failed: input array '%v' with key '%d', expected '%d', get '%d'", test.name, test.data, test.key, test.expected, actualValue)
13 }
14 if !errors.Is(test.expectedError, actualError) {
15 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)
16 }
17 }
18}
19
20func TestBinaryIterative(t *testing.T) {
21 for _, test := range searchTests {

Callers

nothing calls this directly

Calls 1

BinaryFunction · 0.85

Tested by

no test coverage detected