from optimizer.utils.intbounds import IntBounds


class TestIntBounds(object):
    def test_make_gt(self):
        i0 = IntBounds()

        i1 = i0.make_gt(IntBounds(10, 10))

        assert i1.lower == 11

    def test_make_gt_already_bounded(self):
        i0 = IntBounds()

        i1 = i0.make_gt(IntBounds(10, 10)).make_gt(IntBounds(0, 0))

        assert i1.lower == 11

    def test_make_lt(self):
        i0 = IntBounds()

        i1 = i0.make_lt(IntBounds(10, 10))

        assert i1.upper == 9

    def test_make_lt_already_bounded(self):
        i0 = IntBounds()

        i1 = i0.make_lt(IntBounds(0, 0)).make_lt(IntBounds(10, 10))

        assert i1.upper == -1

    def test_both_bounds(self):
        i0 = IntBounds()

        i1 = i0.make_lt(IntBounds(10, 10)).make_gt(IntBounds(0, 0))

        assert i1.upper == 9
        assert i1.lower == 1

        i2 = i0.make_gt(IntBounds(0, 0)).make_lt(IntBounds(10, 10))

        assert i2.lower == 1
        assert i2.upper == 9

    def test_make_le_already_bounded(self):
        i0 = IntBounds()
        i1 = i0.make_le(IntBounds(0, 0)).make_le(IntBounds(2, 2))

        assert i1.upper == 0

    def test_make_ge_already_bounded(self):
        i0 = IntBounds()
        i1 = i0.make_ge(IntBounds(10, 10)).make_ge(IntBounds(0, 0))

        assert i1.lower == 10

[((6, 13, 6, 24), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({}, {}), '()', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((13, 13, 13, 24), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({}, {}), '()', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((20, 13, 20, 24), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({}, {}), '()', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((27, 13, 27, 24), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({}, {}), '()', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((34, 13, 34, 24), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({}, {}), '()', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((47, 13, 47, 24), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({}, {}), '()', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((53, 13, 53, 24), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({}, {}), '()', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((8, 24, 8, 41), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(8, 34, 8, 36): '10', (8, 38, 8, 40): '10'}, {}), '(10, 10)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((15, 51, 15, 66), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(15, 61, 15, 62): '0', (15, 64, 15, 65): '0'}, {}), '(0, 0)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((22, 24, 22, 41), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(22, 34, 22, 36): '10', (22, 38, 22, 40): '10'}, {}), '(10, 10)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((29, 49, 29, 66), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(29, 59, 29, 61): '10', (29, 63, 29, 65): '10'}, {}), '(10, 10)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((36, 51, 36, 66), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(36, 61, 36, 62): '0', (36, 64, 36, 65): '0'}, {}), '(0, 0)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((41, 49, 41, 66), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(41, 59, 41, 61): '10', (41, 63, 41, 65): '10'}, {}), '(10, 10)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((48, 49, 48, 64), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(48, 59, 48, 60): '2', (48, 62, 48, 63): '2'}, {}), '(2, 2)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((54, 51, 54, 66), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(54, 61, 54, 62): '0', (54, 64, 54, 65): '0'}, {}), '(0, 0)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((15, 24, 15, 41), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(15, 34, 15, 36): '10', (15, 38, 15, 40): '10'}, {}), '(10, 10)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((29, 24, 29, 39), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(29, 34, 29, 35): '0', (29, 37, 29, 38): '0'}, {}), '(0, 0)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((36, 24, 36, 41), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(36, 34, 36, 36): '10', (36, 38, 36, 40): '10'}, {}), '(10, 10)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((41, 24, 41, 39), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(41, 34, 41, 35): '0', (41, 37, 41, 38): '0'}, {}), '(0, 0)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((48, 24, 48, 39), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(48, 34, 48, 35): '0', (48, 37, 48, 38): '0'}, {}), '(0, 0)', False, 'from optimizer.utils.intbounds import IntBounds\n'), ((54, 24, 54, 41), 'optimizer.utils.intbounds.IntBounds', 'IntBounds', ({(54, 34, 54, 36): '10', (54, 38, 54, 40): '10'}, {}), '(10, 10)', False, 'from optimizer.utils.intbounds import IntBounds\n')]