def test_is_sorted_on_sorted_integers():
    # Positive test cases (examples) with lists of sorted integers
    assert is_sorted([]) is True  # Empty lists are vacuously sorted
    assert is_sorted([3]) is True  # Single item is trivially sorted
    assert is_sorted([3, 4]) is True  # Duplicate items are in order
    assert is_sorted([3, 5]) is True
    assert is_sorted([3, 5, 7]) is True
Esempio n. 2
0
 def test_sorting(self):
     self.assertEquals(print(is_sorted([1, 2, 3, 4, 4, 5, 6]), True))
     self.assertEquals(print(is_sorted([1, 2, 3, 4, 4, 5, 5]), True))
     self.assertEquals(print(is_sorted([1, 2, 3, 4, 4, 5, 2]), False))
     self.assertEquals(print(is_sorted([]), True))
     self.assertEquals(
         print(is_sorted([1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), True))
def test_is_sorted_on_sorted_strings():
    # Positive test cases (examples) with lists of sorted strings
    assert is_sorted(['A']) is True  # Single item is trivially sorted
    assert is_sorted(['A', 'B']) is True  # Duplicate items are in order
    assert is_sorted(['A', 'C']) is True
    assert is_sorted(['A', 'B', 'C']) is True
def test_is_sorted_on_unsorted_strings():
    # Negative test cases (counterexamples) with lists of unsorted strings
    assert is_sorted(['B', 'A']) is False
    assert is_sorted(['D', 'A', 'C']) is False
    assert is_sorted(['C', 'B', 'A']) is False
def test_is_sorted_on_unsorted_integers():
    # Negative test cases (counterexamples) with lists of unsorted integers
    assert is_sorted([5, 3]) is False
    assert is_sorted([3, 5, 2]) is False
    assert is_sorted([7, 5, 3]) is False
Esempio n. 6
0
 def test_is_sorted_2(self):
     self.assertEqual(is_sorted([0, 1, 2, 2, 2, 3, 100, 10000]), True)
Esempio n. 7
0
 def test_is_sorted_1(self):
     self.assertEqual(is_sorted([]), True)
Esempio n. 8
0
 def test_is_sorted_4(self):
     self.assertEqual(is_sorted([1, 2, 3, 4, 6, 7, 89, 8]), False)
Esempio n. 9
0
 def test_is_sorted_3(self):
     self.assertEqual(is_sorted([1, 1, 0]), False)