From 037999a0a96424a0a662a1a39eefe5f6b84ca3e1 Mon Sep 17 00:00:00 2001 From: Tommy Schaefer Date: Fri, 15 Jul 2016 00:07:22 -0700 Subject: [PATCH 1/3] Add test data for "binary" exercise --- binary.json | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 binary.json diff --git a/binary.json b/binary.json new file mode 100644 index 0000000000..d1cffde843 --- /dev/null +++ b/binary.json @@ -0,0 +1,54 @@ +{ + "cases": [ + { + "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": "invalid binary numbers raise an error", + "binary": ["012", "10nope", "nope10", "10nope10", "001 nope", "2"], + "expected": -1 + } + ] +} From acdf6731e75fdb5b3cc9b3bae233d5abe858b4db Mon Sep 17 00:00:00 2001 From: Tommy Schaefer Date: Sun, 24 Jul 2016 19:28:34 -0500 Subject: [PATCH 2/3] Change generic "cases" key to "decimal" --- binary.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binary.json b/binary.json index d1cffde843..fdd132283e 100644 --- a/binary.json +++ b/binary.json @@ -1,5 +1,5 @@ { - "cases": [ + "decimal": [ { "description": "binary 0 is decimal 0", "binary": "0", From dd43e6683bc8a7cce1c8089eba0b30e776c4a0b2 Mon Sep 17 00:00:00 2001 From: Tommy Schaefer Date: Sun, 24 Jul 2016 19:39:57 -0500 Subject: [PATCH 3/3] Split error cases into two more descriptive cases --- binary.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/binary.json b/binary.json index fdd132283e..f0dc267c2c 100644 --- a/binary.json +++ b/binary.json @@ -46,8 +46,13 @@ "expected": 31 }, { - "description": "invalid binary numbers raise an error", - "binary": ["012", "10nope", "nope10", "10nope10", "001 nope", "2"], + "description": "numbers other than one and zero raise an error", + "binary": ["012", "2"], + "expected": -1 + }, + { + "description": "containing letters raises an error", + "binary": ["10nope", "nope10", "10nope10", "001 nope"], "expected": -1 } ]