mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 01:18:02 +00:00
@@ -95,9 +95,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class MyLinkedList(LinkedList):\n",
|
||||
@@ -126,32 +124,30 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_partition.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestPartition(object):\n",
|
||||
"class TestPartition(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_partition(self):\n",
|
||||
" print('Test: Empty list')\n",
|
||||
" linked_list = MyLinkedList(None)\n",
|
||||
" linked_list.partition(10)\n",
|
||||
" assert_equal(linked_list.get_all_data(), [])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [])\n",
|
||||
"\n",
|
||||
" print('Test: One element list, left list empty')\n",
|
||||
" linked_list = MyLinkedList(Node(5))\n",
|
||||
" linked_list.partition(0)\n",
|
||||
" assert_equal(linked_list.get_all_data(), [5])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [5])\n",
|
||||
"\n",
|
||||
" print('Test: Right list is empty')\n",
|
||||
" linked_list = MyLinkedList(Node(5))\n",
|
||||
" linked_list.partition(10)\n",
|
||||
" assert_equal(linked_list.get_all_data(), [5])\n",
|
||||
" self.assertEqual(linked_list.get_all_data(), [5])\n",
|
||||
"\n",
|
||||
" print('Test: General case')\n",
|
||||
" # Partition = 10\n",
|
||||
@@ -167,7 +163,7 @@
|
||||
" linked_list.insert_to_front(3)\n",
|
||||
" linked_list.insert_to_front(4)\n",
|
||||
" partitioned_list = linked_list.partition(10)\n",
|
||||
" assert_equal(partitioned_list.get_all_data(),\n",
|
||||
" self.assertEqual(partitioned_list.get_all_data(),\n",
|
||||
" [4, 3, 8, 1, 10, 10, 13, 14, 12])\n",
|
||||
"\n",
|
||||
" print('Success: test_partition')\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