-
-
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
Changes from 4 commits
0c589fa
86dd64e
7c13fb8
5d23849
0ea99f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
{ | ||
"exercise": "binary-search-tree", | ||
"version": "1.0.0", | ||
"comments": [ | ||
"Each test case assumes an empty/new tree.", | ||
"As per exercism/problem-specifications#996 key 'tree_data' counts as an input", | ||
"to test generators.", | ||
"The key 'tree_data' represents an array of numbers for which 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...", | ||
"This canonical-data does not restrict the data type of array elements to either", | ||
"strings or integers.", | ||
"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", | ||
"input": { | ||
"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", | ||
"input": { | ||
"tree_data": ["4", "2"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": { | ||
"data": "4", | ||
"left": { | ||
"data": "2", | ||
"left": null, | ||
"right": null | ||
}, | ||
"right": null | ||
} | ||
}, | ||
{ | ||
"description": "same number at left node", | ||
"property": "data", | ||
"input": { | ||
"tree_data": ["4", "4"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": { | ||
"data": "4", | ||
"left": { | ||
"data": "4", | ||
"left": null, | ||
"right": null | ||
}, | ||
"right": null | ||
} | ||
}, | ||
{ | ||
"description": "greater number at right node", | ||
"property": "data", | ||
"input": { | ||
"tree_data": ["4", "5"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": { | ||
"data": "4", | ||
"left": null, | ||
"right": { | ||
"data": "5", | ||
"left": null, | ||
"right": null | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "can create complex tree", | ||
"property": "data", | ||
"input": { | ||
"tree_data": ["4", "2", "6", "1", "3", "5", "7"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"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", | ||
"input": { | ||
"tree_data": ["2"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": ["2"] | ||
}, | ||
{ | ||
"description": "can sort if second number is smaller than first", | ||
"property": "sortedData", | ||
"input": { | ||
"tree_data": ["2", "1"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": ["1", "2"] | ||
}, | ||
{ | ||
"description": "can sort if second number is same as first", | ||
"property": "sortedData", | ||
"input": { | ||
"tree_data": ["2", "2"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": ["2", "2"] | ||
}, | ||
{ | ||
"description": "can sort if second number is greater than first", | ||
"property": "sortedData", | ||
"input": { | ||
"tree_data": ["2", "3"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": ["2", "3"] | ||
}, | ||
{ | ||
"description": "can sort complex tree", | ||
"property": "sortedData", | ||
"input": { | ||
"tree_data": ["2", "1", "3", "6", "7", "5"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be lowerCamelCase in accordance with #987. |
||
}, | ||
"expected": ["1", "2", "3", "5", "6", "7"] | ||
} | ||
] | ||
} | ||
] | ||
} |
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.
@coriolinus @Insti
I just saw issue #987
Should the input key
tree_data
be changed to lowerCamelCase?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.
From what I understand #998 is not allowing additional properties. so does #987 make sense here?
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 have a mild preference for
snake_case
overlowerCamelCase
, but TBH I didn't even think about the applicability of #987 here.As I understand it, the driving intent behind that issue was to avoid using keys which require special handling because they contain spaces or otherwise are not permissible as variable names. As that's handled by either naming convention, I don't have a preference one way or the other about whether you should update your cases here.