From a88f0a0b0bf432cad81ef9c8357f9f36180cbab8 Mon Sep 17 00:00:00 2001 From: Marek Piskorek Date: Wed, 30 Nov 2016 13:41:16 +0100 Subject: [PATCH] Add two more test cases for string compress coding challenge. (#125) * Add two more test cases for string compress coding challenge. I believe that the existing test cases are not strict enough to assure a proper solution for this challenge. I was able to implement a wrong, but still passing solution to this basing on set and collections.Counter mechanism, since the test cases present only situations with singular occurrences of a letter chain and all the test strings are alphabetically sorted. I believe that the two new test cases enforce more thorough approach to the problem and, in effect, the test cases are more descriptive. * Fix the results in tests since the solution changed in the meantine on original branch. * Update also the test_compress and solution. --- arrays_strings/compress/compress_challenge.ipynb | 2 ++ arrays_strings/compress/compress_solution.ipynb | 2 ++ arrays_strings/compress/test_compress.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/arrays_strings/compress/compress_challenge.ipynb b/arrays_strings/compress/compress_challenge.ipynb index 2eb0f8f..19f8496 100644 --- a/arrays_strings/compress/compress_challenge.ipynb +++ b/arrays_strings/compress/compress_challenge.ipynb @@ -123,6 +123,8 @@ " assert_equal(func(''), '')\n", " assert_equal(func('AABBCC'), 'AABBCC')\n", " assert_equal(func('AAABCCDDDDE'), 'A3BC2D4E')\n", + " assert_equal(func('BAAACCDDDD'), 'BA3C2D4')\n", + " assert_equal(func('AAABAACCDDDD'), 'A3BA2C2D4')\n", " print('Success: test_compress')\n", "\n", "\n", diff --git a/arrays_strings/compress/compress_solution.ipynb b/arrays_strings/compress/compress_solution.ipynb index b61ecf4..fbceb59 100644 --- a/arrays_strings/compress/compress_solution.ipynb +++ b/arrays_strings/compress/compress_solution.ipynb @@ -153,6 +153,8 @@ " assert_equal(func(''), '')\n", " assert_equal(func('AABBCC'), 'AABBCC')\n", " assert_equal(func('AAABCCDDDDE'), 'A3BC2D4E')\n", + " assert_equal(func('BAAACCDDDD'), 'BA3C2D4')\n", + " assert_equal(func('AAABAACCDDDD'), 'A3BA2C2D4')\n", " print('Success: test_compress')\n", "\n", "\n", diff --git a/arrays_strings/compress/test_compress.py b/arrays_strings/compress/test_compress.py index e0828d6..6395f11 100644 --- a/arrays_strings/compress/test_compress.py +++ b/arrays_strings/compress/test_compress.py @@ -8,6 +8,8 @@ class TestCompress(object): assert_equal(func(''), '') assert_equal(func('AABBCC'), 'AABBCC') assert_equal(func('AAABCCDDDDE'), 'A3BC2D4E') + assert_equal(func('BAAACCDDDD'), 'BA3C2D4') + assert_equal(func('AAABAACCDDDD'), 'A3BA2C2D4') print('Success: test_compress')