Example. Testing contains with assert

[comp1110-1E]

Take the contains function again from Example [comp1110-1A] and Example [comp1110-16]. Let us test it using assert:

void main() { int[] a1 = new int[]{1,2,3,4,5}; assert (contains(a1, 0) == false); assert (contains(a1,5)); assert (contains(a1,3)); int[] a2 = new int[]{-2, 0, 1000000}; assert (contains(a2, -2)); assert (!contains(a2,5)); }

Try to make each of these tests fail by modifying only the function contains.

bars magnifying-glass caret-down plus minus arrow-right xmark