Merge branch 'irheart-reverse_string/check-inplace'

* irheart-reverse_string/check-inplace:
  Add in-place reverse string test to solution notebook.
  Test for inplace modification of the array.
This commit is contained in:
Donne Martin 2016-02-09 04:47:10 -05:00
commit 81f0f0c1af
3 changed files with 28 additions and 6 deletions

View File

@ -121,10 +121,17 @@
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n", " ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
" print('Success: test_reverse')\n", " print('Success: test_reverse')\n",
"\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", "\n",
"def main():\n", "def main():\n",
" test = TestReverse()\n", " test = TestReverse()\n",
" test.test_reverse()\n", " test.test_reverse()\n",
" test.test_reverse_inplace()\n",
"\n", "\n",
"\n", "\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",

View File

@ -170,10 +170,17 @@
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n", " ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
" print('Success: test_reverse')\n", " print('Success: test_reverse')\n",
"\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", "\n",
"def main():\n", "def main():\n",
" test = TestReverse()\n", " test = TestReverse()\n",
" test.test_reverse()\n", " test.test_reverse()\n",
" test.test_reverse_inplace()\n",
"\n", "\n",
"\n", "\n",
"if __name__ == '__main__':\n", "if __name__ == '__main__':\n",
@ -191,7 +198,8 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Success: test_reverse\n" "Success: test_reverse\n",
"Success: test_reverse_inplace\n"
] ]
} }
], ],
@ -281,21 +289,21 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 2", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python2" "name": "python3"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {
"name": "ipython", "name": "ipython",
"version": 2 "version": 3
}, },
"file_extension": ".py", "file_extension": ".py",
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython2", "pygments_lexer": "ipython3",
"version": "2.7.10" "version": "3.4.3"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -11,10 +11,17 @@ class TestReverse(object):
['r', 'a', 'b', ' ', 'o', 'o', 'f']) ['r', 'a', 'b', ' ', 'o', 'o', 'f'])
print('Success: test_reverse') 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(): def main():
test = TestReverse() test = TestReverse()
test.test_reverse() test.test_reverse()
test.test_reverse_inplace()
if __name__ == '__main__': if __name__ == '__main__':