From 05b29a6e2491e73e1703d2e5ff39611821f75eb4 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 23 Jan 2016 13:00:58 -0800 Subject: [PATCH 1/2] largest-series-product: Test all combinations of corner cases The original tests had tests for "" and 0. This is when both inputs are the boundary condition. Now we should also test when only one input is at the boundary. So we should test a non-empty string with 0, and "" with a nonzero span. These are consistent with the values defined in https://github.com/exercism/x-common/blob/master/largest-series-product.json --- largest-series-product/largest_series_product_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/largest-series-product/largest_series_product_test.py b/largest-series-product/largest_series_product_test.py index bc5b72dc1a..4545288c14 100644 --- a/largest-series-product/largest_series_product_test.py +++ b/largest-series-product/largest_series_product_test.py @@ -34,13 +34,20 @@ def test_big_number(self): series = "52677741234314237566414902593461595376319419139427" self.assertEqual(28350, largest_product(series, 6)) - def test_identity(self): + def test_identity_with_empty_string(self): self.assertEqual(1, largest_product("", 0)) + def test_identity_with_nonempty_string(self): + self.assertEqual(1, largest_product("123", 0)) + def test_slices_bigger_than_number(self): with self.assertRaises(ValueError): largest_product("012", 4) + def test_nonzero_slice_size_and_empty_string(self): + with self.assertRaises(ValueError): + largest_product("", 1) + if __name__ == '__main__': unittest.main() From 46f1a4d8df5d66a3dd907116c20ba66aa2a4edad Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 23 Jan 2016 13:01:58 -0800 Subject: [PATCH 2/2] largest-series-product: Add cases where all spans contain a 0 In these cases, the result should be 0 as well. This guards against solutions that assume the minimum is 1. --- largest-series-product/largest_series_product_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/largest-series-product/largest_series_product_test.py b/largest-series-product/largest_series_product_test.py index 4545288c14..da891a5bff 100644 --- a/largest-series-product/largest_series_product_test.py +++ b/largest-series-product/largest_series_product_test.py @@ -34,6 +34,12 @@ def test_big_number(self): series = "52677741234314237566414902593461595376319419139427" self.assertEqual(28350, largest_product(series, 6)) + def test_string_with_all_zeroes(self): + self.assertEqual(0, largest_product("0000", 2)) + + def test_string_where_all_spans_contain_zero(self): + self.assertEqual(0, largest_product("99099", 3)) + def test_identity_with_empty_string(self): self.assertEqual(1, largest_product("", 0))