コード例 #1
0
ファイル: TestBasicRegex.py プロジェクト: ulikoehler/cffi_re2
 def test_re_compatibility(self):
     """Test compatibility with the Python re library"""
     #
     cm = cffi_re2.search(r'a(b+)', "abbc")
     rm = pyre.search(r'a(b+)', "abbc")
     assert_equal(cm.groups(), rm.groups())
     #
     cm = cffi_re2.match(r'b+', 'abbcd')
     rm = pyre.match(r'b+', 'abbcd')
     assert_equal(cm, rm)
     # Match without groups
     cm = cffi_re2.match(r'[abc]+', 'abbcd')
     rm = pyre.match(r'[abc]+', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     # Full match regex should match
     cm = cffi_re2.match(r'([abc]+)', 'abbcd')
     rm = pyre.match(r'([abc]+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     cm = cffi_re2.match(r'([ab]+)(c+)', 'abbcd')
     rm = pyre.match(r'([ab]+)(c+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     assert_equal(cm.group(2), rm.group(2))
コード例 #2
0
ファイル: TestBasicRegex.py プロジェクト: vls/cffi_re2
 def test_re_compatibility(self):
     """Test compatibility with the Python re library"""
     #
     cm = cffi_re2.search(r'a(b+)', "abbc")
     rm = pyre.search(r'a(b+)', "abbc")
     assert_equal(cm.groups(), rm.groups())
     #
     cm = cffi_re2.match(r'b+', 'abbcd')
     rm = pyre.match(r'b+', 'abbcd')
     assert_equal(cm, rm)
     # Match without groups
     cm = cffi_re2.match(r'[abc]+', 'abbcd')
     rm = pyre.match(r'[abc]+', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     # Full match regex should match
     cm = cffi_re2.match(r'([abc]+)', 'abbcd')
     rm = pyre.match(r'([abc]+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     cm = cffi_re2.match(r'([ab]+)(c+)', 'abbcd')
     rm = pyre.match(r'([ab]+)(c+)', 'abbcd')
     assert_equal(cm.groups(), rm.groups())
     assert_equal(cm.group(0), rm.group(0))
     assert_equal(cm.group(1), rm.group(1))
     assert_equal(cm.group(2), rm.group(2))
コード例 #3
0
ファイル: TestBasicRegex.py プロジェクト: vls/cffi_re2
 def test_module_level_functions(self):
     """
     Quick test of module-level functions.
     These are generally expected to call the compiled counterparts,
      so these tests do not check all aspects
     """
     assert_equal(cffi_re2.findall(r'a(b+)', "abbcdefabbbbca"), ["bb", "bbbb"])
     assert_equal(cffi_re2.sub(r'b+', '', 'abbcbbd'), 'acd')
     assert_is_not_none(cffi_re2.search(r'b+', 'abbcbbd'))
     assert_is_none(cffi_re2.match(r'b+', 'abbcbbd'))
     assert_is_not_none(cffi_re2.match(r'b+', 'bbbbb'))
コード例 #4
0
ファイル: TestBasicRegex.py プロジェクト: ulikoehler/cffi_re2
 def test_module_level_functions(self):
     """
     Quick test of module-level functions.
     These are generally expected to call the compiled counterparts,
      so these tests do not check all aspects
     """
     assert_equal(cffi_re2.findall(r'a(b+)', "abbcdefabbbbca"),
                  ["bb", "bbbb"])
     assert_equal(cffi_re2.sub(r'b+', '', 'abbcbbd'), 'acd')
     assert_is_not_none(cffi_re2.search(r'b+', 'abbcbbd'))
     assert_is_none(cffi_re2.match(r'b+', 'abbcbbd'))
     assert_is_not_none(cffi_re2.match(r'b+', 'bbbbb'))
コード例 #5
0
ファイル: TestBasicRegex.py プロジェクト: ulikoehler/cffi_re2
 def test_optional_groups(self):
     result = cffi_re2.search(r"(foo)?bar", "bar")
     print(result.ranges)
     assert_equal(result.group(0), "bar")
     assert_is_none(result.group(1))
     assert_equal(result.groups(), (None, ))
コード例 #6
0
ファイル: TestBasicRegex.py プロジェクト: ulikoehler/cffi_re2
 def test_more_x(self):
     assert_is_none(cffi_re2.search(r"<(a|span|div|table)", "Kapazitäten"))
     assert_equal(cffi_re2.findall(r"<(a|span|div|table)", "Kapazitäten"),
                  [])
コード例 #7
0
ファイル: TestBasicRegex.py プロジェクト: vls/cffi_re2
 def test_optional_groups(self):
     result = cffi_re2.search(r"(foo)?bar", "bar")
     print(result.ranges)
     assert_equal(result.group(0), "bar")
     assert_is_none(result.group(1))
     assert_equal(result.groups(), (None,))
コード例 #8
0
ファイル: TestBasicRegex.py プロジェクト: vls/cffi_re2
 def test_more_x(self):
     assert_is_none(cffi_re2.search(r"<(a|span|div|table)", "Kapazitäten"))
     assert_equal(cffi_re2.findall(r"<(a|span|div|table)", "Kapazitäten"), [])