mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
the 'Two or more elements' test doesn't actually test if the list was sorted properly
This commit is contained in:
parent
b44cb247b7
commit
e78657f4a4
|
@ -106,18 +106,18 @@
|
||||||
" def test_merge_sort(self):\n",
|
" def test_merge_sort(self):\n",
|
||||||
" print('Empty input')\n",
|
" print('Empty input')\n",
|
||||||
" data = []\n",
|
" data = []\n",
|
||||||
" merge_sort(data)\n",
|
" sorted_data = merge_sort(data)\n",
|
||||||
" assert_equal(data, [])\n",
|
" assert_equal(sorted_data, [])\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('One element')\n",
|
" print('One element')\n",
|
||||||
" data = [5]\n",
|
" data = [5]\n",
|
||||||
" merge_sort(data)\n",
|
" sorted_data = merge_sort(data)\n",
|
||||||
" assert_equal(data, [5])\n",
|
" assert_equal(sorted_data, [5])\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Two or more elements')\n",
|
" print('Two or more elements')\n",
|
||||||
" data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n",
|
" data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n",
|
||||||
" data = merge_sort(data)\n",
|
" sorted_data = merge_sort(data)\n",
|
||||||
" assert_equal(data, sorted(data))\n",
|
" assert_equal(sorted_data, sorted(data))\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_merge_sort')\n",
|
" print('Success: test_merge_sort')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
|
@ -154,18 +154,18 @@
|
||||||
" def test_merge_sort(self):\n",
|
" def test_merge_sort(self):\n",
|
||||||
" print('Empty input')\n",
|
" print('Empty input')\n",
|
||||||
" data = []\n",
|
" data = []\n",
|
||||||
" merge_sort(data)\n",
|
" sorted_data = merge_sort(data)\n",
|
||||||
" assert_equal(data, [])\n",
|
" assert_equal(sorted_data, [])\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('One element')\n",
|
" print('One element')\n",
|
||||||
" data = [5]\n",
|
" data = [5]\n",
|
||||||
" merge_sort(data)\n",
|
" sorted_data = merge_sort(data)\n",
|
||||||
" assert_equal(data, [5])\n",
|
" assert_equal(sorted_data, [5])\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Two or more elements')\n",
|
" print('Two or more elements')\n",
|
||||||
" data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n",
|
" data = [5, 1, 7, 2, 6, -3, 5, 7, -1]\n",
|
||||||
" data = merge_sort(data)\n",
|
" sorted_data = merge_sort(data)\n",
|
||||||
" assert_equal(data, sorted(data))\n",
|
" assert_equal(sorted_data, sorted(data))\n",
|
||||||
"\n",
|
"\n",
|
||||||
" print('Success: test_merge_sort')\n",
|
" print('Success: test_merge_sort')\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
|
@ -5,18 +5,18 @@ class TestMergeSort(object):
|
||||||
def test_merge_sort(self):
|
def test_merge_sort(self):
|
||||||
print('Empty input')
|
print('Empty input')
|
||||||
data = []
|
data = []
|
||||||
merge_sort(data)
|
sorted_data = merge_sort(data)
|
||||||
assert_equal(data, [])
|
assert_equal(sorted_data, [])
|
||||||
|
|
||||||
print('One element')
|
print('One element')
|
||||||
data = [5]
|
data = [5]
|
||||||
merge_sort(data)
|
sorted_data = merge_sort(data)
|
||||||
assert_equal(data, [5])
|
assert_equal(sorted_data, [5])
|
||||||
|
|
||||||
print('Two or more elements')
|
print('Two or more elements')
|
||||||
data = [5, 1, 7, 2, 6, -3, 5, 7, -1]
|
data = [5, 1, 7, 2, 6, -3, 5, 7, -1]
|
||||||
data = merge_sort(data)
|
sorted_data = merge_sort(data)
|
||||||
assert_equal(data, sorted(data))
|
assert_equal(sorted_data, sorted(data))
|
||||||
|
|
||||||
print('Success: test_merge_sort')
|
print('Success: test_merge_sort')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user