def testHas(self):
        # array of { lower, upper,
        #            lower_inclusive, upper_inclusive 
        #            testValue, expected }
        data = [
            # inclusive boundaries
            [1, 8, True, True, 2, True],
            [1, 8, True, True, 1, True],
            [1, 8, True, True, 8, True],
            [1, 8, True, True, 0, False],
            [1, 8, True, True, 9, False],
            [Smallest(), 8, False, True, 4, True],
            [Smallest(), 8, False, True, -1, True],
            [Smallest(), 8, False, True, 9, False],
            [1, Largest(), True, False, 4, True],
            [1, Largest(), True, False, 1, True],
            [1, Largest(), True, False, -1, False],
            # exclusive boundaries
            [1, 8, False, False, 2, True],
            [1, 8, False, False, 1, False],
            [1, 8, False, False, 8, False],
            [1, 8, False, False, 0, False],
            [1, 8, False, False, 9, False],
            [Smallest(), 8, False, False, 4, True],
            [Smallest(), 8, False, False, -1, True],
            [Smallest(), 8, False, False, 9, False],
            [1, Largest(), False, False, 4, True],
            [1, Largest(), False, False, 1, False],
            [1, Largest(), False, False, -1, False]
        ]

        for lower, upper, lower_inclusive, upper_inclusive, test_value, expected in data:
            iv = Interval(lower, upper, lower_inclusive, upper_inclusive)
            self.assertEqual(iv.has(test_value), expected)
Exemple #2
0
 def __init__(self, lower, upper, lower_included=None, upper_included=None):
     Interval.__init__(self, lower, upper, lower_included, upper_included)