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: Add test data for "binary" exercise #296

Merged
merged 3 commits into from
Jul 25, 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
59 changes: 59 additions & 0 deletions binary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"decimal": [
{
"description": "binary 0 is decimal 0",
"binary": "0",
"expected": 0
},
{
"description": "binary 1 is decimal 1",
"binary": "1",
"expected": 1
},
{
"description": "binary 10 is decimal 2",
"binary": "10",
"expected": 2
},
{
"description": "binary 11 is decimal 3",
"binary": "11",
"expected": 3
},
{
"description": "binary 100 is decimal 4",
"binary": "100",
"expected": 4
},
{
"description": "binary 1001 is decimal 9",
"binary": "1001",
"expected": 9
},
{
"description": "binary 11010 is decimal 26",
"binary": "11010",
"expected": 26
},
{
"description": "binary 10001101000 is decimal 1128",
"binary": "10001101000",
"expected": 1128
},
{
"description": "binary ignores leading zeros",
"binary": "000011111",
"expected": 31
},
{
"description": "numbers other than one and zero raise an error",
"binary": ["012", "2"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should become 2 tests,

         "description": "2 is not a valid binary digit and so should raise an error",
         "binary":  "2",
         "expected" :  null,

and

         "description": "A number containing an invalid binary digit is invalid and should raise an error",
         "binary":  "01201",
         "expected":  null,

Discussion required: I'm not 100% sure null is the correct expected value here if we want to indicate in a general way that an error should be raised.

"expected": -1
},
{
"description": "containing letters raises an error",
"binary": ["10nope", "nope10", "10nope10", "001 nope"],
Copy link
Contributor

@Insti Insti Jul 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary should never be an array.
See my other comment above about splitting arrays into individual tests.

"expected": -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure -1 is the right value to expect in the case of an error, it probably should be null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think -1 is fine as long as we note somewhere that it's a place-holder for an error. Each track can deal with it as they please.

}
]
}