Exemple #1
0
 def test_clamp_unbounded(self):
     self.assertEqual(clamp(42), 42)
     self.assertEqual(clamp(-42), -42)
     self.assertEqual(clamp(121, min_=13), 121)
     self.assertEqual(clamp(-121, min_=13), 13)
     self.assertEqual(clamp(121, max_=13), 13)
     self.assertEqual(clamp(-121, max_=13), -121)
Exemple #2
0
 def test_clamp_values(self):
     self.assertEqual(clamp(1, 2, 3), 2)
     self.assertEqual(clamp(4, 3, 5), 4)
     self.assertEqual(clamp(10, 8, 9), 9)
     self.assertEqual(clamp(-1, 0, 1), 0)
     self.assertEqual(clamp(1, -1, 0), 0)