def test_swap_k_1(self): """ Test empty list """ L = [] k = 0 a1.swap_k(L, k) expected = [] self.assertEqual(L, expected)
def test_empty(self): """ Test empty list """ L = [] a1.swap_k(L, 0) self.assertEquals(len(L),0)
def test_swapk_1(self): """ test with even list and even k""" nums = [1, 2, 3, 4, 5, 6] a1.swap_k(nums, 2) actual = nums expected = [5, 6, 3, 4, 1, 2] self.assertEqual(actual, expected)
def test_one(self): """ Test list with only one element """ L = [1] a1.swap_k(L, 1) self.assertEquals(L[0],1)
def test_swap_k_4(self): """ Test 1 < k < len(L) // 2 """ L = [1, 2, 3, 4, 5, 6] k = 2 a1.swap_k(L, k) expected = [5, 6, 3, 4, 1, 2] self.assertEqual(L, expected)
def test_swap_example2(self): '''Testing Boundaries: the smallest list where the order can be changed''' nums = [10,20] a1.swap_k(nums, 1) actual = nums expected = [20, 10] self.assertEqual(actual, expected)
def test_1_item(self): """ Test a single-item list -- smallest non-empty list and smallest list with an odd number of items.""" L = [1] L_expected = [1] a1.swap_k(L, 0) self.assertEqual(L, L_expected)
def test_2_item(self): """ Test swap on 2-item list -- the smallest list that actually be swapped, and smallest list with an even number of items.""" L = [1, 2] L_expected = [2, 1] a1.swap_k(L, 1) self.assertEqual(L, L_expected)
def test_swap_k_even_length_list_and_k_0(self): """ Test swap_k with a input of even length list and k=0 """ test_list = [ 1, 2, 3, 4 ] a1.swap_k(test_list, 0) expected_result = [ 1, 2, 3, 4 ] self.assertEqual(test_list, expected_result)
def test_swap_k_empty_list(self): """ Test swap_k with a input ofn empty list """ test_list = [] a1.swap_k(test_list, 0) expected_result = [] self.assertEqual(test_list, expected_result)
def test_swap_example1(self): '''Testing Boundaries & Size: an empty list first''' nums = [] a1.swap_k(nums, 0) actual = nums expected = [] self.assertEqual(actual, expected)
def test_swap_k_even_length_list_and_k_1(self): """ Test swap_k with a input of an even length list and k=1 """ test_list = [ 1, 2, 3, 4 ] a1.swap_k(test_list, 1) expected_result = [ 4, 2, 3, 1 ] self.assertEqual(test_list, expected_result)
def test_swap_k_one_element_list(self): """ Test swap_k with a input of a list of one element """ test_list = [ 1 ] a1.swap_k(test_list, 0) expected_result = [ 1 ] self.assertEqual(test_list, expected_result)
def test_swap_k_two_element_list_and_k_zero(self): """ Test swap_k with a input of a list of 2 elements and k=0 """ test_list = [ 1, 2 ] a1.swap_k(test_list, 0) expected_result = [ 1, 2 ] self.assertEqual(test_list, expected_result)
def test_swap_k_even_element_list_and_kmax(self): """Test swap_k with an even length list and k=len(L)//2.""" L = [1, 2, 3, 4, 5, 6] a1.swap_k(L, 3) expected = [4, 5, 6, 1, 2, 3] self.assertEqual(L, expected)
def test_swap_k_odd_element_list_and_kmax(self): """Test swap_k with an odd length list and k=len(L)//2.""" L = [1, 2, 3, 4, 5] a1.swap_k(L, 2) expected = [4, 5, 3, 1, 2] self.assertEqual(L, expected)
def test_swap_k_empty_list(self): """Test swap_k with an empty list.""" L = [] a1.swap_k(L, 0) expected = [] self.assertEqual(L, expected)
def test_swap_k_2(self): """ Test single element case and k = 0 case """ L = [1] k = 0 a1.swap_k(L, k) expected = [1] self.assertEqual(L, expected)
def test_swap_k_3(self): """ Test k = 1 """ L = [1, 2, 3, 4, 5, 6] k = 1 a1.swap_k(L, k) expected = [6, 2, 3, 4, 5, 1] self.assertEqual(L, expected)
def test_swap_example3(self): '''Testing Dichotomy: a list with an odd length''' nums = [10,20,30] a1.swap_k(nums, 1) actual = nums expected = [30, 20, 10] self.assertEqual(actual, expected)
def test_swap_k_odd_length_list_and_k_1(self): """ Test swap_k with a input of an odd length list and and k=1 """ test_list = [ 1, 2, 3, 4, 5 ] a1.swap_k(test_list, 1) expected_result = [ 5, 2, 3, 4, 1 ] self.assertEqual(test_list, expected_result)
def test_swap_example4(self): '''Testing Size & Dichotomy: a large list with an even number of elements''' nums = [1, 2, 3, 4, 5, 6] a1.swap_k(nums, 2) actual = nums expected = [5, 6, 3, 4, 1, 2] self.assertEqual(actual, expected)
def test_swap_k_where_list_has_5_items(self): ''' Test swap_k when the list has 5 items and k == 1''' actual_list = [1, 2, 3, 4, 5] expected = [5, 2, 3, 4, 1] a1.swap_k(actual_list, 1) self.assertEqual(expected, actual_list)
def test_swapk_6(self): """ test with odd list and even k """ nums = [9, 8, 7, 6, 5, 4, 3] a1.swap_k(nums, 3) actual = nums expected = [5, 4, 3, 6, 9, 8, 7] self.assertEqual(actual, expected)
def test_swap_k_where_list_is_empty(self): ''' Test swap_k when the list is empty and k == 0''' actual_list = [] expected = [] a1.swap_k(actual_list, 0) self.assertEqual(expected, actual_list)
def test_swap_k_where_list_has_1_item(self): ''' Test swap_k when the list has 1 item k == 0''' actual_list = [1] expected = [1] a1.swap_k(actual_list, 0) self.assertEqual(expected, actual_list)
def test_swap_k_long_list(self): """Test swap_k with long list of even values.""" nums = [1, 2, 3, 4, 5, 6] a1.swap_k(nums, 2) expected = [5, 6, 3, 4, 1, 2] self.assertEqual(expected, nums)
def test_one_item_swapped(self): """ Swapping 1/3 of an even array.""" actual = [1, 2, 3, 4, 5, 6] a1.swap_k(actual, 1) expected = [6, 2, 3, 4, 5, 1] self.assertEqual(expected, actual)
def test_testswap_k_example_2(self): """Test the case when k == 1.""" nums = [1,2] a1.swap_k(nums,1) actual = nums expected = [2,1] self.assertEqual(expected,actual)
def test_zero_item_swapped(self): """ None swapping.""" actual = [1, 2, 3, 4, 5, 6] a1.swap_k(actual, 0) expected = [1, 2, 3, 4, 5, 6] self.assertEqual(expected, actual)
def test_one_item_list(self): """ None swapping on one item list.""" actual = [1] a1.swap_k(actual, 0) expected = [1] self.assertEqual(expected, actual)
def test_swap_k_two_element_list_and_k1(self): """Test swap_k with one element list, i.e. a singleton list, and k=1.""" L = [1, 2] a1.swap_k(L, 1) expected = [2, 1] self.assertEqual(L, expected)
def test_half_item_swapped(self): """ Swapping half of an even array.""" actual = [1, 2, 3, 4, 5, 6] a1.swap_k(actual, 3) expected = [4, 5, 6, 1, 2, 3] self.assertEqual(expected, actual)
def test_swap_k_long_odd(self): """Test swap k with a long odd length list.""" nums = [1,2,3,4,5,6,7] a1.swap_k(nums,3) expected = [5, 6, 7, 4, 1, 2, 3] self.assertEqual(expected, nums)
def test_swap_k_1(self): """Test swap_k with [1, 2, 3, 4, 5, 6] and 2""" nums = [1, 2, 3, 4, 5, 6] expected = [5, 6, 3, 4, 1, 2] a1.swap_k(nums, 2) self.assertEqual(expected, nums)
def test_swap_k_short_list(self): """Test swap_k with short list.""" nums = [1,2,3] a1.swap_k(nums,1) expected = [3, 2, 1] self.assertEqual(expected, nums)
def test_swap_k_zero_k(self): """Test swap_k where k is 0.""" nums = [1, 2, 3] a1.swap_k(nums,0) expected = [1, 2, 3] self.assertEqual(expected, nums)
def test_swap_k_one_element_list_and_k0(self): """Test swap_k with one element list, i.e. a singleton list, and k=0.""" L = [1] a1.swap_k(L, 0) expected = [1] self.assertEqual(L, expected)
def test_swap_k_5(self): """ Test k = len(L) // 2 """ L = [1, 2, 3, 4, 5, 6] k = 3 a1.swap_k(L, k) expected = [4, 5, 6, 1, 2, 3] self.assertEqual(L, expected)
def test_swap_k_two_element_list_and_k0(self): """Test swap_k with two element list and k=0.""" L = [1, 2] a1.swap_k(L, 0) expected = [1, 2] self.assertEqual(L, expected)
def test_testswap_k_example_3(self): """Test the case when k > 1.""" nums = [1,2,3,4,5] a1.swap_k(nums,2) actual = nums expected = [4,5,3,1,2] self.assertEqual(expected,actual)
def test_swap_k_where_list_has_4_items(self): ''' Test swap_k when the list has 4 items and k == 2''' actual_list = [1, 2, 3, 4] expected = [3, 4, 1, 2] a1.swap_k(actual_list, 2) self.assertEqual(expected, actual_list)
def test_testswap_k_example_1(self): """Test the case when k == 0, thus L keeps the same, no matter how long L is.""" nums = [1,2,3,4,5,6] a1.swap_k(nums, 0) actual = nums expected = [1,2,3,4,5,6] self.assertEqual(expected,actual)
def test_max_swap_odd(self): nums = [1, 2, 3, 4, 5, 6, 7] nums_expected = [5, 6, 7, 4, 1, 2, 3] k = 3 a1.swap_k(nums,k) self.assertEqual(nums, nums_expected)
def test_swap_k_even_list_all(self): """Test swap_k with an even list where all values are swapped.""" nums = [1, 2, 3, 4] a1.swap_k(nums, 2) expected = [3, 4, 1, 2] self.assertEqual(expected, nums)
def test_two_elements_swap(self): """Test two elements with k = 1, should reverse the list""" L = [1, 2] k = 1 L_expected = [2, 1] a1.swap_k(L, k) self.assertEquals(L_expected, L)
def test_no_swap(self): nums = [1, 2, 3, 4, 5, 6] nums_expected = [1, 2, 3, 4, 5, 6] k = 0 a1.swap_k(nums,0) self.assertEqual(nums, nums_expected)
def test_max_swap_even(self): nums = [1, 2, 3, 4, 5, 6] nums_expected = [4, 5, 6, 1, 2, 3] k = 3 a1.swap_k(nums,k) self.assertEqual(nums, nums_expected)
def test_swapk_3(self): """ Test swapk_k for an empty list. The return value should also be an empty list """ actualList = [] expectedList = [] a1.swap_k(actualList, 0) self.assertEqual(expectedList, actualList)
def test_two_case_two(self): """ two element list passed with arg k = 0 """ num = [1,2] k = 0 num_expected = [1,2] a1.swap_k(num,k) self.assertEqual(num, num_expected)
def test_general_odd(self): """ five element general list passed with arg k = 2 """ num = [1,2,3,4,5] k = 2 num_expected = [4,5,3,1,2] a1.swap_k(num,k) self.assertEqual(num, num_expected)
def test_three_case_two(self): """ three element list passed with arg k = 1 """ num = [1,2,3] k = 1 num_expected = [3,2,1] a1.swap_k(num,k) self.assertEqual(num, num_expected)
def test_null_case(self): """ empty list passed with arg k = 0 """ num = [] k = 0 num_expected = [] a1.swap_k(num,k) self.assertEqual(num, num_expected)
def test_general_even(self): """ four element general list passed with arg k = 1 """ num = [1,2,3,4] k = 1 num_expected = [4,2,3,1] a1.swap_k(num,k) self.assertEqual(num, num_expected)
def test_general_even_two(self): """ four element general list passed with arg k = 2 """ num = [1,2,3,4] k = 2 num_expected = [3,4,1,2] a1.swap_k(num,k) self.assertEqual(num, num_expected)
def test_swapk_example_2(self): """Test swap_k with nums = [1, 2, 3]. and dont swap any | nums, 0 """ nums = [1, 2, 3] nums_expected = [1, 2, 3] a1.swap_k(nums, 0) self.assertEqual(nums, nums_expected)
def test_swapk_example_3(self): """Test swap_k with nums = [1, 1, 1, 1, 1, 1]. and have all the numbers the same and swap 4 """ nums = [1, 1, 1, 1, 1, 1] nums_expected = [1, 1, 1, 1, 1, 1] a1.swap_k(nums, 4) self.assertEqual(nums, nums_expected)
def test_one_case_two(self): """ single element list passed with arg k = 1 """ num = [1] k = 1 num_expected = [1] a1.swap_k(num,k) self.assertEqual(num, num_expected)
def test_swapk_example_4(self): """Test swap_k with nums = [2, 3] swapping a list with only 2 in the list but askign for 2 to be swapped """ nums = [2, 3] nums_expected = [2, 3] a1.swap_k(nums, 2) self.assertEqual(nums, nums_expected)
def test_swapk_example_1(self): """Test swap_k with nums = [1, 2, 3, 4, 5, 6]. and swap the last 2 """ nums = [1, 2, 3, 4, 5, 6] nums_expected = [ 5, 6, 3, 4, 1, 2] a1.swap_k(nums, 2) self.assertEqual(nums, nums_expected)