-
-
Notifications
You must be signed in to change notification settings - Fork 550
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-tree: implement canonical-data.json #940
Merged
ErikSchierboom
merged 5 commits into
exercism:master
from
devkabiir:binary-search-tree-tests
Jan 5, 2018
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c589fa
binary-search-tree: implement canonical-data.json
devkabiir 86dd64e
add proposed changes
devkabiir 7c13fb8
update input schema as per #996
devkabiir 5d23849
remove ambiguous key
devkabiir 0ea99f7
binary-search-tree: "tree_data" -> "treeData"
rpottsoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,154 @@ | ||
{ | ||
"exercise": "binary-search-tree", | ||
"version": "1.0.0", | ||
"comments": [ | ||
"Each test case assumes an empty/new tree.", | ||
"The key 'tree_data' represents an array of numbers the data should be ", | ||
"inserted/added to the tree as it appears in the array from left to right.", | ||
"e.g. tree_data: ['2', '1', '3', '6', '7', '5']", | ||
"Insert 2. Insert 1. Insert 3. Insert 6, so on...", | ||
"The key 'expected' represents tree state as JSON object of schema :", | ||
"{", | ||
" 'title':'nodeObject',", | ||
" 'type':'object',", | ||
" 'properties':{", | ||
" 'data':{", | ||
" 'type':'string'", | ||
" },", | ||
" 'left':{", | ||
" 'type':'nodeObject'", | ||
" },", | ||
" 'right':{", | ||
" 'type':'nodeObject'", | ||
" }", | ||
" },", | ||
" 'required':['data', 'left', 'right']", | ||
"}" | ||
], | ||
"cases": [{ | ||
"description": "data is retained", | ||
"property": "data", | ||
"tree_data": ["4"], | ||
"expected": { | ||
"data": "4", | ||
"left": null, | ||
"right": null | ||
} | ||
}, | ||
{ | ||
"description": "insert data at proper node", | ||
"cases": [{ | ||
"description": "smaller number at left node", | ||
"property": "data", | ||
"tree_data": ["4", "2"], | ||
"expected": { | ||
"data": "4", | ||
"left": { | ||
"data": "2", | ||
"left": null, | ||
"right": null | ||
}, | ||
"right": null | ||
} | ||
}, | ||
{ | ||
"description": "same number at left node", | ||
"property": "data", | ||
"node": "root->left", | ||
"tree_data": ["4", "4"], | ||
"expected": { | ||
"data": "4", | ||
"left": { | ||
"data": "4", | ||
"left": null, | ||
"right": null | ||
}, | ||
"right": null | ||
} | ||
}, | ||
{ | ||
"description": "greater number at right node", | ||
"property": "data", | ||
"tree_data": ["4", "5"], | ||
"expected": { | ||
"data": "4", | ||
"left": null, | ||
"right": { | ||
"data": "5", | ||
"left": null, | ||
"right": null | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "can create complex tree", | ||
"property": "data", | ||
"tree_data": ["4", "2", "6", "1", "3", "5", "7"], | ||
"expected": { | ||
"data": "4", | ||
"left": { | ||
"data": "2", | ||
"left": { | ||
"data": "1", | ||
"left": null, | ||
"right": null | ||
}, | ||
"right": { | ||
"data": "3", | ||
"left": null, | ||
"right": null | ||
} | ||
}, | ||
"right": { | ||
"data": "6", | ||
"left": { | ||
"data": "5", | ||
"left": null, | ||
"right": null | ||
}, | ||
"right": { | ||
"data": "7", | ||
"left": null, | ||
"right": null | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"description": "can sort data", | ||
"cases": [{ | ||
"description": "can sort single number", | ||
"property": "sortedData", | ||
"tree_data": ["2"], | ||
"expected": ["2"] | ||
}, | ||
{ | ||
"description": "can sort if second number is smaller than first", | ||
"property": "sortedData", | ||
"tree_data": ["2", "1"], | ||
"expected": ["1", "2"] | ||
}, | ||
{ | ||
"description": "can sort if second number is same as first", | ||
"property": "sortedData", | ||
"tree_data": ["2", "2"], | ||
"expected": ["2", "2"] | ||
}, | ||
{ | ||
"description": "can sort if second number is greater than first", | ||
"property": "sortedData", | ||
"tree_data": ["2", "3"], | ||
"expected": ["2", "3"] | ||
}, | ||
{ | ||
"description": "can sort complex tree", | ||
"property": "sortedData", | ||
"tree_data": ["2", "1", "3", "6", "7", "5"], | ||
"expected": ["1", "2", "3", "5", "6", "7"] | ||
} | ||
] | ||
} | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this file you have taken your suggestion of #940 (comment) to use
expected
to represent the entire tree, and not your suggestion of #940 (comment) to list one specific node being traversed to. If you confirm this is true, I think thisnode
line should be removed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!, good catch.