|
| 1 | +module main |
| 2 | + |
| 3 | +const empty = []int{cap: 0} |
| 4 | + |
| 5 | +fn test_empty_lists() { |
| 6 | + assert compare(empty, empty) == .equal |
| 7 | +} |
| 8 | + |
| 9 | +fn test_empty_list_within_non_empty_list() { |
| 10 | + list_two := [1, 2, 3] |
| 11 | + assert compare(empty, list_two) == .sublist |
| 12 | +} |
| 13 | + |
| 14 | +fn test_non_empty_list_contains_empty_list() { |
| 15 | + list_one := [1, 2, 3] |
| 16 | + assert compare(list_one, empty) == .superlist |
| 17 | +} |
| 18 | + |
| 19 | +fn test_list_equals_itself() { |
| 20 | + list_one := [1, 2, 3] |
| 21 | + list_two := [1, 2, 3] |
| 22 | + assert compare(list_one, list_two) == .equal |
| 23 | +} |
| 24 | + |
| 25 | +fn test_different_lists() { |
| 26 | + list_one := [1, 2, 3] |
| 27 | + list_two := [2, 3, 4] |
| 28 | + assert compare(list_one, list_two) == .unequal |
| 29 | +} |
| 30 | + |
| 31 | +fn test_false_start() { |
| 32 | + list_one := [1, 2, 5] |
| 33 | + list_two := [0, 1, 2, 3, 1, 2, 5, 6] |
| 34 | + assert compare(list_one, list_two) == .sublist |
| 35 | +} |
| 36 | + |
| 37 | +fn test_consecutive() { |
| 38 | + list_one := [1, 1, 2] |
| 39 | + list_two := [0, 1, 1, 1, 2, 1, 2] |
| 40 | + assert compare(list_one, list_two) == .sublist |
| 41 | +} |
| 42 | + |
| 43 | +fn test_sublist_at_start() { |
| 44 | + list_one := [0, 1, 2] |
| 45 | + list_two := [0, 1, 2, 3, 4, 5] |
| 46 | + assert compare(list_one, list_two) == .sublist |
| 47 | +} |
| 48 | + |
| 49 | +fn test_sublist_in_middle() { |
| 50 | + list_one := [2, 3, 4] |
| 51 | + list_two := [0, 1, 2, 3, 4, 5] |
| 52 | + assert compare(list_one, list_two) == .sublist |
| 53 | +} |
| 54 | + |
| 55 | +fn test_sublist_at_end() { |
| 56 | + list_one := [3, 4, 5] |
| 57 | + list_two := [0, 1, 2, 3, 4, 5] |
| 58 | + assert compare(list_one, list_two) == .sublist |
| 59 | +} |
| 60 | + |
| 61 | +fn test_at_start_of_superlist() { |
| 62 | + list_one := [0, 1, 2, 3, 4, 5] |
| 63 | + list_two := [0, 1, 2] |
| 64 | + assert compare(list_one, list_two) == .superlist |
| 65 | +} |
| 66 | + |
| 67 | +fn test_in_middle_of_superlist() { |
| 68 | + list_one := [0, 1, 2, 3, 4, 5] |
| 69 | + list_two := [2, 3] |
| 70 | + assert compare(list_one, list_two) == .superlist |
| 71 | +} |
| 72 | + |
| 73 | +fn test_at_end_of_superlist() { |
| 74 | + list_one := [0, 1, 2, 3, 4, 5] |
| 75 | + list_two := [3, 4, 5] |
| 76 | + assert compare(list_one, list_two) == .superlist |
| 77 | +} |
| 78 | + |
| 79 | +fn test_first_list_missing_element_from_second_list() { |
| 80 | + list_one := [1, 3] |
| 81 | + list_two := [1, 2, 3] |
| 82 | + assert compare(list_one, list_two) == .unequal |
| 83 | +} |
| 84 | + |
| 85 | +fn test_second_list_missing_element_from_first_list() { |
| 86 | + list_one := [1, 2, 3] |
| 87 | + list_two := [1, 3] |
| 88 | + assert compare(list_one, list_two) == .unequal |
| 89 | +} |
| 90 | + |
| 91 | +fn test_first_list_missing_additional_digits_from_second_list() { |
| 92 | + list_one := [1, 2] |
| 93 | + list_two := [1, 22] |
| 94 | + assert compare(list_one, list_two) == .unequal |
| 95 | +} |
| 96 | + |
| 97 | +fn test_order_matters_to_a_list() { |
| 98 | + list_one := [1, 2, 3] |
| 99 | + list_two := [3, 2, 1] |
| 100 | + assert compare(list_one, list_two) == .unequal |
| 101 | +} |
| 102 | + |
| 103 | +fn test_same_digits_but_different_numbers() { |
| 104 | + list_one := [1, 0, 1] |
| 105 | + list_two := [10, 1] |
| 106 | + assert compare(list_one, list_two) == .unequal |
| 107 | +} |
0 commit comments