示例#1
0
    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)
示例#2
0
 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)
示例#3
0
 def test_with_single_binary_gap_of_one_0(self):
     num = int("101", 2)
     exp = 1
     act = bg.solution(num)
     self.assertEquals(exp, act)
示例#4
0
 def test_with_single_binary_gap_of_multipe_0s(self):
     num = int("10001", 2)
     exp = 3
     act = bg.solution(num)
     self.assertEquals(exp, act)
示例#5
0
 def test_with_0s_at_start(self):
     num = int("0011", 2)
     exp = 0
     act = bg.solution(num)
     self.assertEquals(exp, act)
示例#6
0
 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
示例#10
0
 def test_solution_1610612737(self):
     N = 1610612737
     assert solution(N) == 28
示例#11
0
 def test_solution_74901729(self):
     N = 74901729
     assert solution(N) == 4
示例#12
0
 def test_solution_6291457(self):
     N = 6291457
     assert solution(N) == 20
示例#13
0
 def test_solution_66561(self):
     N = 66561
     assert solution(N) == 9
def test_binary_gap(N, expected):
    assert solution(N) == expected
示例#15
0
 def test_with_only_1s(self):
     num = int("111", 2)
     exp = 0
     act = bg.solution(num)
     self.assertEquals(exp, act)
示例#16
0
 def test_solution(self):
     self.assertEqual(binary_gap.solution(1), 0)
示例#17
0
 def test_solution_51712(self):
     N = 51712
     assert solution(N) == 2