예제 #1
0
파일: strings.py 프로젝트: srimalik/samba
    def test_strstr_m(self):
        # A, B, strstr_m(A, B)
        cases = [('hello', 'hello', 'hello'),
                 ('hello', 'goodbye', None),
                 ('goodbye', 'hello', None),
                 ('hell', 'hello', None),
                 ('hello', 'hell', 'hello'),
                 ('', '', ''),
                 ('a', '', 'a'),
                 ('', 'a', None),
                 ('a', 'A', None),
                 ('aa', 'aA', None),
                 ('Aa', 'aa', None),
                 ('%v foo', '%v', '%v foo'),
                 ('foo %v foo', '%v', '%v foo'),
                 ('foo %v', '%v', '%v'),
                 ('longstring ' * 100, 'longstring ' * 99, 'longstring ' * 100),
                 ('longstring ' * 99, 'longstring ' * 100, None),
                 ('longstring a' * 99, 'longstring ' * 100 + 'a', None),
                 ('longstring ' * 100 + 'a', 'longstring ' * 100, 'longstring ' * 100 + 'a'),
                 (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', None),
                 (KATAKANA_LETTER_A + 'bcde', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcde'),
                 ('d'+KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd'),
                 ('d'+KATAKANA_LETTER_A + 'bd', KATAKANA_LETTER_A + 'bcd', None),

                 ('e'+KATAKANA_LETTER_A + 'bcdf', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcdf'),
                 (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', None),
                 (KATAKANA_LETTER_A*3, 'a', None),
                 ]
        for a, b, expect in cases:
            if expect is not None:
                expect = expect.encode('utf-8')
            self.assertEquals(strstr_m(a.encode('utf-8'),
                                       b.encode('utf-8')),
                              expect)
예제 #2
0
 def test_strstr_m(self):
     # A, B, strstr_m(A, B)
     cases = [
         ('hello', 'hello', 'hello'),
         ('hello', 'goodbye', None),
         ('goodbye', 'hello', None),
         ('hell', 'hello', None),
         ('hello', 'hell', 'hello'),
         ('', '', ''),
         ('a', '', 'a'),
         ('', 'a', None),
         ('a', 'A', None),
         ('aa', 'aA', None),
         ('Aa', 'aa', None),
         ('%v foo', '%v', '%v foo'),
         ('foo %v foo', '%v', '%v foo'),
         ('foo %v', '%v', '%v'),
         ('longstring ' * 100, 'longstring ' * 99, 'longstring ' * 100),
         ('longstring ' * 99, 'longstring ' * 100, None),
         ('longstring a' * 99, 'longstring ' * 100 + 'a', None),
         ('longstring ' * 100 + 'a', 'longstring ' * 100,
          'longstring ' * 100 + 'a'),
         (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', None),
         (KATAKANA_LETTER_A + 'bcde', KATAKANA_LETTER_A + 'bcd',
          KATAKANA_LETTER_A + 'bcde'),
         ('d' + KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd',
          KATAKANA_LETTER_A + 'bcd'),
         ('d' + KATAKANA_LETTER_A + 'bd', KATAKANA_LETTER_A + 'bcd', None),
         ('e' + KATAKANA_LETTER_A + 'bcdf', KATAKANA_LETTER_A + 'bcd',
          KATAKANA_LETTER_A + 'bcdf'),
         (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', None),
         (KATAKANA_LETTER_A * 3, 'a', None),
     ]
     for a, b, expect in cases:
         self.assertEqual(strstr_m(a, b), expect)