Пример #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)
Пример #7
0
 def test_solution_5(self, ):
     N = 5
     assert solution(N) == 1
Пример #8
0
 def test_solution_561892(self):
     N = 561892
     assert solution(N) == 3
Пример #9
0
 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
Пример #14
0
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