forked from exercism/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request exercism#599 from ricemery/binary-search
Upday binary-search exeprcise to match latest test data. Refs exercism#488
- Loading branch information
Showing
1 changed file
with
22 additions
and
15 deletions.
There are no files selected for viewing
37 changes: 22 additions & 15 deletions
37
exercises/binary-search/src/test/scala/BinarySearchTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |