本文整理汇总了Python中solution.count_substrings函数的典型用法代码示例。如果您正苦于以下问题:Python count_substrings函数的具体用法?Python count_substrings怎么用?Python count_substrings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了count_substrings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_longer_strings
def test_with_longer_strings(self):
self.assertEqual(solution.count_substrings('either kill or be killed',
'kill'),
2)
self.assertEqual(solution.count_substrings("a beard doesn't make one" +
" a philosopher",
"yeaaap"),
0)
示例2: test_count_substrings
def test_count_substrings(self):
self.assertEqual(2, count_substrings("This is a test string", "is"))
# 2
self.assertEqual(2, count_substrings("babababa", "baba"))
# 2
self.assertEqual(
4, count_substrings("Python is an awesome language to program in!", "o"))
# 4
self.assertEqual(
0, count_substrings("We have nothing in common!", "really?"))
# 0
self.assertEqual(
2, count_substrings("This is this and that is this", "this"))
示例3: test_count_substrings
def test_count_substrings(self):
self.assertEqual(2, solution.count_substrings("This is a test string", "is"))
self.assertEqual(4, solution.count_substrings("Python is an awesome language to program in!", "o"))
示例4: test_with_two_digit_substring
def test_with_two_digit_substring(self):
self.assertEqual(2, solution.count_substrings("This is a test string", "is"))
示例5: test_with_no_matches
def test_with_no_matches(self):
self.assertEqual(0, solution.count_substrings("We have nothing in common!", "really?"))
示例6: test_two
def test_two(self):
self.assertEqual(2, count_substrings("babababa", "baba"))
示例7: test_five
def test_five(self):
self.assertEqual(2, count_substrings("This is this and that is this", "this"))
示例8: test_three
def test_three(self):
self.assertEqual(4, count_substrings("Python is an awesome language to program in!", "o"))
示例9: test_capital_letters
def test_capital_letters(self):
self.assertTrue(solution.count_substrings("This is this and that is this", "this"))
示例10: testing_count_substring2
def testing_count_substring2(self):
self.assertEqual(2, count_substrings("babababa", "baba"))
示例11: test_with_single_character_strings
def test_with_single_character_strings(self):
self.assertEqual(solution.count_substrings('ala bala portokala', 'a'),
6)
self.assertEqual(solution.count_substrings('yo', 'w'), 0)
示例12: test_does_not_count_overlapped_strings
def test_does_not_count_overlapped_strings(self):
self.assertEqual(solution.count_substrings('hahahahahahahahaha', 'ha'),
9)
示例13: test_takes_case_into_consideration
def test_takes_case_into_consideration(self):
self.assertEqual(solution.count_substrings("This ain't this!", 'this'),
1)
示例14: test_count_substrings_3rd
def test_count_substrings_3rd(self):
self.assertEqual(4, solution.count_substrings("Python is an awesome language to program in!", "o"))
示例15: test_contains_string
def test_contains_string(self):
self.assertTrue(solution.count_substrings("This is a test string", "is"))