Missing test in exercise "binary search"

Currently there is no test for a null-buffer in the “binary search” exercise.

A test like this would be needed:

test "nothing is found if the array is null" {
    try testing.expectError(SearchError.EmptyBuffer, binarySearch(isize, 13, null));
}

Right now, solutions that simply remove the optional part from the solution template work fine, for example this one:

Alternatively, just make the buffer non-optional throughout the exercise.

I’m already in the process of addressing this :)

I was leaning towards that.

Furthermore, I’ll propose that binarySearch returns an optional. That’s also what the Zig stdlib does.

Related: exercises: consider replacing some errors with optionals/asserts/assumes · Issue #229 · exercism/zig · GitHub

1 Like

Awesome, thank you!