From e78657f4a42d419dfccd32eb72012fd6e447d83c Mon Sep 17 00:00:00 2001 From: Justin LeFebvre Date: Mon, 13 Jul 2015 00:33:07 -0400 Subject: [PATCH] the 'Two or more elements' test doesn't actually test if the list was sorted properly --- .../merge_sort/merge_sort_challenge.ipynb | 12 ++++++------ .../merge_sort/merge_sort_solution.ipynb | 12 ++++++------ sorting_searching/merge_sort/test_merge_sort.py | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sorting_searching/merge_sort/merge_sort_challenge.ipynb b/sorting_searching/merge_sort/merge_sort_challenge.ipynb index ea45a2d..76f4e8c 100644 --- a/sorting_searching/merge_sort/merge_sort_challenge.ipynb +++ b/sorting_searching/merge_sort/merge_sort_challenge.ipynb @@ -106,18 +106,18 @@ " def test_merge_sort(self):\n", " print('Empty input')\n", " data = []\n", - " merge_sort(data)\n", - " assert_equal(data, [])\n", + " sorted_data = merge_sort(data)\n", + " assert_equal(sorted_data, [])\n", "\n", " print('One element')\n", " data = [5]\n", - " merge_sort(data)\n", - " assert_equal(data, [5])\n", + " sorted_data = merge_sort(data)\n", + " assert_equal(sorted_data, [5])\n", "\n", " print('Two or more elements')\n", " data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n", - " data = merge_sort(data)\n", - " assert_equal(data, sorted(data))\n", + " sorted_data = merge_sort(data)\n", + " assert_equal(sorted_data, sorted(data))\n", "\n", " print('Success: test_merge_sort')\n", "\n", diff --git a/sorting_searching/merge_sort/merge_sort_solution.ipynb b/sorting_searching/merge_sort/merge_sort_solution.ipynb index 14fed90..99cd77f 100644 --- a/sorting_searching/merge_sort/merge_sort_solution.ipynb +++ b/sorting_searching/merge_sort/merge_sort_solution.ipynb @@ -154,18 +154,18 @@ " def test_merge_sort(self):\n", " print('Empty input')\n", " data = []\n", - " merge_sort(data)\n", - " assert_equal(data, [])\n", + " sorted_data = merge_sort(data)\n", + " assert_equal(sorted_data, [])\n", "\n", " print('One element')\n", " data = [5]\n", - " merge_sort(data)\n", - " assert_equal(data, [5])\n", + " sorted_data = merge_sort(data)\n", + " assert_equal(sorted_data, [5])\n", "\n", " print('Two or more elements')\n", " data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n", - " data = merge_sort(data)\n", - " assert_equal(data, sorted(data))\n", + " sorted_data = merge_sort(data)\n", + " assert_equal(sorted_data, sorted(data))\n", "\n", " print('Success: test_merge_sort')\n", "\n", diff --git a/sorting_searching/merge_sort/test_merge_sort.py b/sorting_searching/merge_sort/test_merge_sort.py index a68cd54..ce41c43 100644 --- a/sorting_searching/merge_sort/test_merge_sort.py +++ b/sorting_searching/merge_sort/test_merge_sort.py @@ -5,18 +5,18 @@ class TestMergeSort(object): def test_merge_sort(self): print('Empty input') data = [] - merge_sort(data) - assert_equal(data, []) + sorted_data = merge_sort(data) + assert_equal(sorted_data, []) print('One element') data = [5] - merge_sort(data) - assert_equal(data, [5]) + sorted_data = merge_sort(data) + assert_equal(sorted_data, [5]) print('Two or more elements') data = [5, 1, 7, 2, 6, -3, 5, 7, -1] - data = merge_sort(data) - assert_equal(data, sorted(data)) + sorted_data = merge_sort(data) + assert_equal(sorted_data, sorted(data)) print('Success: test_merge_sort')