Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binary-search: add json test data #349

Merged
merged 1 commit into from
Aug 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions binary-search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"#": [
"Here -1 is used to indicate that the value is not included in the array.",
"It should be replaced with the respective expression that is idiomatic",
"for the language that implements the tests.",

"Following https://github.com/exercism/x-common/issues/234 the exercise",
"should NOT include checking whether the array is sorted as it defeats",
"the point of the binary search.",

"The exercise should utilize an array-like (i.e. constant-time indexed)",
"data structure and not a linked list. If something like an array is not",
"usually used in the language the problem should not be implemented.",
"See https://github.com/exercism/x-common/issues/244 for details."
],
"cases": [
{
"description": "finds a value in an array with one element",
"array": [6],
"value": 6,
"expected": 0
},
{
"description": "finds a value in the middle of an array",
"array": [1, 3, 4, 6, 8, 9, 11],
"value": 6,
"expected": 3
},
{
"description": "finds a value at the beginning of an array",
"array": [1, 3, 4, 6, 8, 9, 11],
"value": 1,
"expected": 0
},
{
"description": "finds a value at the end of an array",
"array": [1, 3, 4, 6, 8, 9, 11],
"value": 11,
"expected": 6
},
{
"description": "finds a value in an array of odd length",
"array": [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634],
"value": 144,
"expected": 9
},
{
"description": "finds a value in an array of even length",
"array": [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377],
"value": 21,
"expected": 5
},
{
"description": "identifies that a value is not included in the array",
"array": [1, 3, 4, 6, 8, 9, 11],
"value": 7,
"expected": -1
},
{
"description": "a value smaller than the array's smallest value is not included",
"array": [1, 3, 4, 6, 8, 9, 11],
"value": 0,
"expected": -1
},
{
"description": "a value larger than the array's largest value is not included",
"array": [1, 3, 4, 6, 8, 9, 11],
"value": 13,
"expected": -1
},
{
"description": "nothing is included in an empty array",
"array": [],
"value": 1,
"expected": -1
}
]
}