'Util.number.ceil_shift'

def test_ceil_shift(self):

    self.assertRaises(AssertionError, number.ceil_shift, (-1), 1)
    self.assertRaises(AssertionError, number.ceil_shift, 1, (-1))
    self.assertEqual(0, number.ceil_shift(0, 0))
    self.assertEqual(1, number.ceil_shift(1, 0))
    self.assertEqual(2, number.ceil_shift(2, 0))
    self.assertEqual(3, number.ceil_shift(3, 0))
    self.assertEqual(0, number.ceil_shift(0, 1))
    self.assertEqual(1, number.ceil_shift(1, 1))
    self.assertEqual(1, number.ceil_shift(2, 1))
    self.assertEqual(2, number.ceil_shift(3, 1))
    self.assertEqual(0, number.ceil_shift(0, 2))
    self.assertEqual(1, number.ceil_shift(1, 2))
    self.assertEqual(1, number.ceil_shift(2, 2))
    self.assertEqual(1, number.ceil_shift(3, 2))
    self.assertEqual(1, number.ceil_shift(4, 2))
    self.assertEqual(2, number.ceil_shift(5, 2))
    self.assertEqual(2, number.ceil_shift(6, 2))
    self.assertEqual(2, number.ceil_shift(7, 2))
    self.assertEqual(2, number.ceil_shift(8, 2))
    self.assertEqual(3, number.ceil_shift(9, 2))
    for b in range(3, (1 + 129), 3):
        self.assertEqual(0, number.ceil_shift(0, b))
        n = 1L
        while (n <= (2L ** (b + 2))):
            (q, r) = divmod((n - 1), (2L ** b))
            expected = (q + int((not (not r))))
            self.assertEqual(((n - 1), b, expected), ((n - 1), b, number.ceil_shift((n - 1), b)))
            (q, r) = divmod(n, (2L ** b))
            expected = (q + int((not (not r))))
            self.assertEqual((n, b, expected), (n, b, number.ceil_shift(n, b)))
            (q, r) = divmod((n + 1), (2L ** b))
            expected = (q + int((not (not r))))
            self.assertEqual(((n + 1), b, expected), ((n + 1), b, number.ceil_shift((n + 1), b)))
            n *= 2
