Beispiel #1
0
 def test_reverseComparator(self):
     reverse35 = ReverseComparator(35)
     reverse36 = ReverseComparator(36)
     self.assertEqual(reverse35, reverse35)
     self.assertNotEqual(reverse35, reverse36)
     self.assertLess(reverse36, reverse35)
     self.assertGreater(reverse35, reverse36)
     self.assertLess(reverse36, reverse35)
Beispiel #2
0
 def test_reverseComparisonWithNone(self):
     noneInList = ["z", None, None, "q", "a", None, "v"]
     sortedList = sorted(noneInList,
                         key=lambda x: ReverseComparator(NoneComparator(x)))
     self.assertEqual(sortedList, ["z", "v", "q", "a", None, None, None])
Beispiel #3
0
 def test_reverseComparison(self):
     nums = [1, 2, 3, 4, 5]
     nums.sort(key=lambda x: ReverseComparator(x))
     self.assertEqual(nums, [5, 4, 3, 2, 1])