def test_with_one_char(self): num = int("0", 2) exp = 0 act = bg.solution(num) self.assertEquals(exp, act) num = int("1", 2) act = bg.solution(num) self.assertEquals(exp, act)
def test_with_multiple_binary_gaps_where_first_is_longest(self): num = int("10010110", 2) exp = 2 act = bg.solution(num) self.assertEquals(exp, act)
def test_with_single_binary_gap_of_one_0(self): num = int("101", 2) exp = 1 act = bg.solution(num) self.assertEquals(exp, act)
def test_with_single_binary_gap_of_multipe_0s(self): num = int("10001", 2) exp = 3 act = bg.solution(num) self.assertEquals(exp, act)
def test_with_0s_at_start(self): num = int("0011", 2) exp = 0 act = bg.solution(num) self.assertEquals(exp, act)
def test_with_0s_at_end(self): num = int("1100", 2) exp = 0 act = bg.solution(num) self.assertEquals(exp, act)
def test_solution_5(self, ): N = 5 assert solution(N) == 1
def test_solution_561892(self): N = 561892 assert solution(N) == 3
def test_solution_1376796946(self): N = 1376796946 assert solution(N) == 5
def test_solution_1610612737(self): N = 1610612737 assert solution(N) == 28
def test_solution_74901729(self): N = 74901729 assert solution(N) == 4
def test_solution_6291457(self): N = 6291457 assert solution(N) == 20
def test_solution_66561(self): N = 66561 assert solution(N) == 9
def test_binary_gap(N, expected): assert solution(N) == expected
def test_with_only_1s(self): num = int("111", 2) exp = 0 act = bg.solution(num) self.assertEquals(exp, act)
def test_solution(self): self.assertEqual(binary_gap.solution(1), 0)
def test_solution_51712(self): N = 51712 assert solution(N) == 2