Fixed #23: Quicksort unit tests aren't correctly testing the returned value from quick_sort.

This commit is contained in:
Donne Martin 2015-07-14 06:50:54 -04:00
parent 7826fc45a7
commit 1d763fd142
3 changed files with 18 additions and 18 deletions

View File

@ -105,18 +105,18 @@
" def test_quick_sort(self, func):\n", " def test_quick_sort(self, func):\n",
" print('Empty input')\n", " print('Empty input')\n",
" data = []\n", " data = []\n",
" func(data)\n", " sorted_data = func(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",
" func(data)\n", " sorted_data = func(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 = func(data)\n", " sorted_data = func(data)\n",
" assert_equal(data, sorted(data))\n", " assert_equal(sorted_data, sorted(data))\n",
"\n", "\n",
" print('Success: test_quick_sort\\n')\n", " print('Success: test_quick_sort\\n')\n",
"\n", "\n",

View File

@ -169,18 +169,18 @@
" def test_quick_sort(self, func):\n", " def test_quick_sort(self, func):\n",
" print('Empty input')\n", " print('Empty input')\n",
" data = []\n", " data = []\n",
" func(data)\n", " sorted_data = func(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",
" func(data)\n", " sorted_data = func(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 = func(data)\n", " sorted_data = func(data)\n",
" assert_equal(data, sorted(data))\n", " assert_equal(sorted_data, sorted(data))\n",
"\n", "\n",
" print('Success: test_quick_sort\\n')\n", " print('Success: test_quick_sort\\n')\n",
"\n", "\n",

View File

@ -5,18 +5,18 @@ class TestQuickSort(object):
def test_quick_sort(self, func): def test_quick_sort(self, func):
print('Empty input') print('Empty input')
data = [] data = []
func(data) sorted_data = func(data)
assert_equal(data, []) assert_equal(sorted_data, [])
print('One element') print('One element')
data = [5] data = [5]
func(data) sorted_data = func(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 = func(data) sorted_data = func(data)
assert_equal(data, sorted(data)) assert_equal(sorted_data, sorted(data))
print('Success: test_quick_sort\n') print('Success: test_quick_sort\n')