mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 17:38:02 +00:00
@@ -95,9 +95,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class MyLinkedList(LinkedList):\n",
|
||||
@@ -126,22 +124,20 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_add_reverse.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestAddReverse(object):\n",
|
||||
"class TestAddReverse(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_add_reverse(self):\n",
|
||||
" print('Test: Empty list(s)')\n",
|
||||
" assert_equal(MyLinkedList().add_reverse(None, None), None)\n",
|
||||
" assert_equal(MyLinkedList().add_reverse(Node(5), None), None)\n",
|
||||
" assert_equal(MyLinkedList().add_reverse(None, Node(10)), None)\n",
|
||||
" self.assertEqual(MyLinkedList().add_reverse(None, None), None)\n",
|
||||
" self.assertEqual(MyLinkedList().add_reverse(Node(5), None), None)\n",
|
||||
" self.assertEqual(MyLinkedList().add_reverse(None, Node(10)), None)\n",
|
||||
"\n",
|
||||
" print('Test: Add values of different lengths')\n",
|
||||
" # Input 1: 6->5->None\n",
|
||||
@@ -153,7 +149,7 @@
|
||||
" second_list.append(8)\n",
|
||||
" second_list.append(7)\n",
|
||||
" result = MyLinkedList().add_reverse(first_list, second_list)\n",
|
||||
" assert_equal(result.get_all_data(), [5, 4, 8])\n",
|
||||
" self.assertEqual(result.get_all_data(), [5, 4, 8])\n",
|
||||
"\n",
|
||||
" print('Test: Add values of same lengths')\n",
|
||||
" # Input 1: 6->5->4\n",
|
||||
@@ -168,7 +164,7 @@
|
||||
" second_list.append(8)\n",
|
||||
" second_list.append(7)\n",
|
||||
" result = MyLinkedList().add_reverse(first_list, second_list)\n",
|
||||
" assert_equal(result.get_all_data(), [5, 4, 2, 1])\n",
|
||||
" self.assertEqual(result.get_all_data(), [5, 4, 2, 1])\n",
|
||||
"\n",
|
||||
" print('Success: test_add_reverse')\n",
|
||||
"\n",
|
||||
@@ -208,9 +204,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user