Skip to content

Commit

Permalink
Merge pull request exercism#599 from ricemery/binary-search
Browse files Browse the repository at this point in the history
Upday binary-search exeprcise to match latest test data. Refs exercism#488
  • Loading branch information
ErikSchierboom committed Jan 1, 2019
2 parents 8d7a29d + f00e387 commit 09561df
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions exercises/binary-search/src/test/scala/BinarySearchTest.scala
Original file line number Diff line number Diff line change
@@ -1,54 +1,61 @@
import org.scalatest.{Matchers, FunSuite}

/** @version 1.1.0 */
/** @version 1.3.0 */
class BinarySearchTest extends FunSuite with Matchers {

test("finds a value in an array with one element") {
BinarySearch.find(List(6), 6) should be (Some(0))
BinarySearch.find(List(6), 6) should be(Some(0))
}

test("finds a value in the middle of an array") {
pending
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 6) should be (Some(3))
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 6) should be(Some(3))
}

test("finds a value at the beginning of an array") {
pending
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 1) should be (Some(0))
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 1) should be(Some(0))
}

test("finds a value at the end of an array") {
pending
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 11) should be (Some(6))
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 11) should be(Some(6))
}

test("finds a value in an array of odd length") {
pending
BinarySearch.find(List(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634), 144) should be (Some(9))
BinarySearch.find(List(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634),
144) should be(Some(9))
}

test("finds a value in an array of even length") {
pending
BinarySearch.find(List(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377), 21) should be (Some(5))
BinarySearch.find(List(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377), 21) should be(
Some(5))
}

test("identifies that a value is not included in the array") {
pending
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 7) should be (None)
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 7) should be(None)
}

test("a value smaller than the array's smallest value is not found") {
pending
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 0) should be(None)
}

test("a value smaller than the array's smallest value is not included") {
test("a value larger than the array's largest value is not found") {
pending
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 0) should be (None)
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 13) should be(None)
}

test("a value larger than the array's largest value is not included") {
test("nothing is found in an empty array") {
pending
BinarySearch.find(List(1, 3, 4, 6, 8, 9, 11), 13) should be (None)
BinarySearch.find(List(), 1) should be(None)
}

test("nothing is included in an empty array") {
test("nothing is found when the left and right bounds cross") {
pending
BinarySearch.find(List(), 1) should be (None)
BinarySearch.find(List(1, 2), 0) should be(None)
}
}

0 comments on commit 09561df

Please sign in to comment.