From 2fd239fbeb7823409425f209018995b5453116d2 Mon Sep 17 00:00:00 2001 From: kmt Date: Wed, 20 Jan 2016 21:40:10 +0300 Subject: [PATCH 1/2] Test for inplace modification of the array. --- .../reverse_string/reverse_string_challenge.ipynb | 7 +++++++ arrays_strings/reverse_string/test_reverse_string.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/arrays_strings/reverse_string/reverse_string_challenge.ipynb b/arrays_strings/reverse_string/reverse_string_challenge.ipynb index 499a0de..5fb4f89 100644 --- a/arrays_strings/reverse_string/reverse_string_challenge.ipynb +++ b/arrays_strings/reverse_string/reverse_string_challenge.ipynb @@ -121,10 +121,17 @@ " ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n", " print('Success: test_reverse')\n", "\n", + " def test_reverse_inplace(self):\n", + " target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']\n", + " list_of_chars(target_list)\n", + " assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n", + " print('Success: test_reverse_inplace')\n", + "\n", "\n", "def main():\n", " test = TestReverse()\n", " test.test_reverse()\n", + " test.test_reverse_inplace()\n", "\n", "\n", "if __name__ == '__main__':\n", diff --git a/arrays_strings/reverse_string/test_reverse_string.py b/arrays_strings/reverse_string/test_reverse_string.py index 688bff7..553d5b3 100644 --- a/arrays_strings/reverse_string/test_reverse_string.py +++ b/arrays_strings/reverse_string/test_reverse_string.py @@ -11,10 +11,17 @@ class TestReverse(object): ['r', 'a', 'b', ' ', 'o', 'o', 'f']) print('Success: test_reverse') + def test_reverse_inplace(self): + target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r'] + list_of_chars(target_list) + assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f']) + print('Success: test_reverse_inplace') + def main(): test = TestReverse() test.test_reverse() + test.test_reverse_inplace() if __name__ == '__main__': From eee55dfa80a228d03bd9265cca4e47b4e3748a4e Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Tue, 9 Feb 2016 04:46:44 -0500 Subject: [PATCH 2/2] Add in-place reverse string test to solution notebook. --- .../reverse_string_solution.ipynb | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arrays_strings/reverse_string/reverse_string_solution.ipynb b/arrays_strings/reverse_string/reverse_string_solution.ipynb index 73c3325..9658372 100644 --- a/arrays_strings/reverse_string/reverse_string_solution.ipynb +++ b/arrays_strings/reverse_string/reverse_string_solution.ipynb @@ -170,10 +170,17 @@ " ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n", " print('Success: test_reverse')\n", "\n", + " def test_reverse_inplace(self):\n", + " target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']\n", + " list_of_chars(target_list)\n", + " assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n", + " print('Success: test_reverse_inplace')\n", + "\n", "\n", "def main():\n", " test = TestReverse()\n", " test.test_reverse()\n", + " test.test_reverse_inplace()\n", "\n", "\n", "if __name__ == '__main__':\n", @@ -191,7 +198,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Success: test_reverse\n" + "Success: test_reverse\n", + "Success: test_reverse_inplace\n" ] } ], @@ -281,21 +289,21 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" + "pygments_lexer": "ipython3", + "version": "3.4.3" } }, "nbformat": 4,