Lines Matching +full:- +full:replace
105 self.checkequal(1, 'aaa', 'count', 'a', -1)
106 self.checkequal(3, 'aaa', 'count', 'a', -10)
109 self.checkequal(2, 'aaa', 'count', 'a', 0, -1)
110 self.checkequal(0, 'aaa', 'count', 'a', 0, -10)
114 self.checkequal(2, 'aaa', 'count', '', -1)
115 self.checkequal(4, 'aaa', 'count', '', -10)
151 r2, rem = divmod(n - len(i.replace(j, self.fixtype(''))),
162 self.checkequal(-1, 'abcdefghiabc', 'find', 'def', 4)
166 self.checkequal(-1, 'abc', 'find', '', 4)
171 self.checkequal(-1, 'rrarrrrrrrrra', 'find', 'a', 4, 6)
178 self.checkequal(-1, 'hello', 'find', 42)
183 self.checkequal(-1, '', 'find', '', 1, 1)
184 self.checkequal(-1, '', 'find', '', sys.maxsize, 0)
186 self.checkequal(-1, '', 'find', 'xx')
187 self.checkequal(-1, '', 'find', 'xx', 1, 1)
188 self.checkequal(-1, '', 'find', 'xx', sys.maxsize, 0)
191 self.checkequal(-1, 'ab', 'find', 'xxx', sys.maxsize + 1, 0)
210 r1 = (loc != -1)
213 if loc != -1:
220 self.checkequal(-1, 'abcdefghiabc', 'rfind', 'abcz')
224 self.checkequal(-1, 'abc', 'rfind', '', 4)
229 self.checkequal(-1, 'rrarrrrrrrrra', 'rfind', 'a', 4, 6)
236 self.checkequal(-1, 'hello', 'rfind', 42)
257 r1 = (loc != -1)
260 if loc != -1:
264 self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0)
278 self.checkraises(ValueError, 'abcdefghi', 'index', 'ghi', -1)
298 self.checkequal(0, 'abcdefghiabc', 'rindex', 'abc', 0, -1)
302 self.checkraises(ValueError, 'defghiabc', 'rindex', 'abc', 0, -1)
304 self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, -1)
368 sys.maxsize-2)
378 self.checkequal(['a']*20, ('a|'*20)[:-1], 'split', '|')
380 ('a|'*20)[:-1], 'split', '|', 15)
389 sys.maxsize-10)
406 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH')
407 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH', 19)
408 self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4],
437 sys.maxsize-100)
448 self.checkequal(['a']*20, ('a|'*20)[:-1], 'rsplit', '|')
450 ('a|'*20)[:-1], 'rsplit', '|', 15)
459 sys.maxsize-5)
476 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH')
477 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH', 19)
478 self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4],
503 EQ("", "", "replace", "", "")
504 EQ("A", "", "replace", "", "A")
505 EQ("", "", "replace", "A", "")
506 EQ("", "", "replace", "A", "A")
507 EQ("", "", "replace", "", "", 100)
508 EQ("A", "", "replace", "", "A", 100)
509 EQ("", "", "replace", "", "", sys.maxsize)
512 EQ("A", "A", "replace", "", "")
513 EQ("*A*", "A", "replace", "", "*")
514 EQ("*1A*1", "A", "replace", "", "*1")
515 EQ("*-#A*-#", "A", "replace", "", "*-#")
516 EQ("*-A*-A*-", "AA", "replace", "", "*-")
517 EQ("*-A*-A*-", "AA", "replace", "", "*-", -1)
518 EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxsize)
519 EQ("*-A*-A*-", "AA", "replace", "", "*-", 4)
520 EQ("*-A*-A*-", "AA", "replace", "", "*-", 3)
521 EQ("*-A*-A", "AA", "replace", "", "*-", 2)
522 EQ("*-AA", "AA", "replace", "", "*-", 1)
523 EQ("AA", "AA", "replace", "", "*-", 0)
526 EQ("", "A", "replace", "A", "")
527 EQ("", "AAA", "replace", "A", "")
528 EQ("", "AAA", "replace", "A", "", -1)
529 EQ("", "AAA", "replace", "A", "", sys.maxsize)
530 EQ("", "AAA", "replace", "A", "", 4)
531 EQ("", "AAA", "replace", "A", "", 3)
532 EQ("A", "AAA", "replace", "A", "", 2)
533 EQ("AA", "AAA", "replace", "A", "", 1)
534 EQ("AAA", "AAA", "replace", "A", "", 0)
535 EQ("", "AAAAAAAAAA", "replace", "A", "")
536 EQ("BCD", "ABACADA", "replace", "A", "")
537 EQ("BCD", "ABACADA", "replace", "A", "", -1)
538 EQ("BCD", "ABACADA", "replace", "A", "", sys.maxsize)
539 EQ("BCD", "ABACADA", "replace", "A", "", 5)
540 EQ("BCD", "ABACADA", "replace", "A", "", 4)
541 EQ("BCDA", "ABACADA", "replace", "A", "", 3)
542 EQ("BCADA", "ABACADA", "replace", "A", "", 2)
543 EQ("BACADA", "ABACADA", "replace", "A", "", 1)
544 EQ("ABACADA", "ABACADA", "replace", "A", "", 0)
545 EQ("BCD", "ABCAD", "replace", "A", "")
546 EQ("BCD", "ABCADAA", "replace", "A", "")
547 EQ("BCD", "BCD", "replace", "A", "")
548 EQ("*************", "*************", "replace", "A", "")
549 EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999)
552 EQ("", "the", "replace", "the", "")
553 EQ("ater", "theater", "replace", "the", "")
554 EQ("", "thethe", "replace", "the", "")
555 EQ("", "thethethethe", "replace", "the", "")
556 EQ("aaaa", "theatheatheathea", "replace", "the", "")
557 EQ("that", "that", "replace", "the", "")
558 EQ("thaet", "thaet", "replace", "the", "")
559 EQ("here and re", "here and there", "replace", "the", "")
561 "replace", "the", "", sys.maxsize)
563 "replace", "the", "", -1)
565 "replace", "the", "", 3)
567 "replace", "the", "", 2)
569 "replace", "the", "", 1)
571 "replace", "the", "", 0)
572 EQ("here and re and re", "here and there and there", "replace", "the", "")
574 EQ("abc", "abc", "replace", "the", "")
575 EQ("abcdefg", "abcdefg", "replace", "the", "")
578 EQ("bob", "bbobob", "replace", "bob", "")
579 EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "")
580 EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "")
581 EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "")
583 # single character replace in place (len(from)==len(to)==1)
584 EQ("Who goes there?", "Who goes there?", "replace", "o", "o")
585 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O")
586 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxsize)
587 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1)
588 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3)
589 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2)
590 EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1)
591 EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0)
593 EQ("Who goes there?", "Who goes there?", "replace", "a", "q")
594 EQ("who goes there?", "Who goes there?", "replace", "W", "w")
595 EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w")
596 EQ("Who goes there!", "Who goes there?", "replace", "?", "!")
597 EQ("Who goes there!!", "Who goes there??", "replace", "?", "!")
599 EQ("Who goes there?", "Who goes there?", "replace", ".", "!")
601 # substring replace in place (len(from)==len(to) > 1)
602 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**")
603 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxsize)
604 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1)
605 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4)
606 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3)
607 EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2)
608 EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1)
609 EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0)
610 EQ("cobob", "bobob", "replace", "bob", "cob")
611 EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob")
612 EQ("bobob", "bobob", "replace", "bot", "bot")
614 # replace single character (len(from)==1, len(to)>1)
615 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK")
616 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1)
617 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxsize)
618 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2)
619 EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1)
620 EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0)
621 EQ("A----B----C----", "A.B.C.", "replace", ".", "----")
623 EQ('...\u043c......<', '...\u043c......<', "replace", "<", "<")
625 EQ("Reykjavik", "Reykjavik", "replace", "q", "KK")
627 # replace substring (len(from)>1, len(to)!=len(from))
629 "replace", "spam", "ham")
631 "replace", "spam", "ham", sys.maxsize)
633 "replace", "spam", "ham", -1)
635 "replace", "spam", "ham", 4)
637 "replace", "spam", "ham", 3)
639 "replace", "spam", "ham", 2)
641 "replace", "spam", "ham", 1)
643 "replace", "spam", "ham", 0)
645 EQ("bobob", "bobobob", "replace", "bobob", "bob")
646 EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob")
647 EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby")
649 self.checkequal('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
650 self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '')
651 self.checkequal('one@two@three!', 'one!two!three!', 'replace', '!', '@', 2)
652 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 3)
653 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 4)
654 self.checkequal('one!two!three!', 'one!two!three!', 'replace', '!', '@', 0)
655 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@')
656 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@')
657 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@', 2)
658 self.checkequal('-a-b-c-', 'abc', 'replace', '', '-')
659 self.checkequal('-a-b-c', 'abc', 'replace', '', '-', 3)
660 self.checkequal('abc', 'abc', 'replace', '', '-', 0)
661 self.checkequal('', '', 'replace', '', '')
662 self.checkequal('abc', 'abc', 'replace', 'ab', '--', 0)
663 self.checkequal('abc', 'abc', 'replace', 'xy', '--')
664 # Next three for SF bug 422088: [OSF1 alpha] string.replace(); died with
667 self.checkequal('', '123', 'replace', '123', '')
668 self.checkequal('', '123123', 'replace', '123', '')
669 self.checkequal('x', '123x123', 'replace', '123', '')
671 self.checkraises(TypeError, 'hello', 'replace')
672 self.checkraises(TypeError, 'hello', 'replace', 42)
673 self.checkraises(TypeError, 'hello', 'replace', 42, 'h')
674 self.checkraises(TypeError, 'hello', 'replace', 'h', 42)
677 'only applies to 32-bit platforms')
681 self.checkraises(OverflowError, A2_16, "replace", "", A2_16)
682 self.checkraises(OverflowError, A2_16, "replace", "A", A2_16)
683 self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16)
741 sys.maxsize-1)
777 sys.maxsize-20)
797 self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1)
874 self.checkequal('-123', '-123', 'zfill', 3)
875 self.checkequal('-123', '-123', 'zfill', 4)
876 self.checkequal('-0123', '-123', 'zfill', 5)
913 self.checkequal(False, 'Not--a Titlecase String', 'istitle')
978 self.checkequal('Format,This-As*Title;String', "fOrMaT,thIs-aS*titLe;String", 'title', )
1019 # check with cased non-letter chars
1028 # check with Ll chars with no upper - nothing changes here
1056 self.checkequal(True, 'hello', 'startswith', 'he', 0, -1)
1057 self.checkequal(True, 'hello', 'startswith', 'he', -53, -1)
1058 self.checkequal(False, 'hello', 'startswith', 'hello', 0, -1)
1059 self.checkequal(False, 'hello', 'startswith', 'hello world', -1, -10)
1060 self.checkequal(False, 'hello', 'startswith', 'ello', -5)
1061 self.checkequal(True, 'hello', 'startswith', 'ello', -4)
1062 self.checkequal(False, 'hello', 'startswith', 'o', -2)
1063 self.checkequal(True, 'hello', 'startswith', 'o', -1)
1064 self.checkequal(True, 'hello', 'startswith', '', -3, -3)
1065 self.checkequal(False, 'hello', 'startswith', 'lo', -9)
1079 self.checkequal(True, 'hello', 'startswith', ('lo', 'he'), 0, -1)
1105 self.checkequal(True, 'hello', 'endswith', 'lo', -2)
1106 self.checkequal(False, 'hello', 'endswith', 'he', -2)
1107 self.checkequal(True, 'hello', 'endswith', '', -3, -3)
1108 self.checkequal(False, 'hello', 'endswith', 'hello world', -10, -2)
1109 self.checkequal(False, 'helloworld', 'endswith', 'worl', -6)
1110 self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, -1)
1111 self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, 9)
1112 self.checkequal(True, 'helloworld', 'endswith', 'world', -7, 12)
1113 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -99, -3)
1114 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -8, -3)
1115 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -7, -3)
1116 self.checkequal(False, 'helloworld', 'endswith', 'lowo', 3, -4)
1117 self.checkequal(False, 'helloworld', 'endswith', 'lowo', -8, -2)
1130 'rld'), 3, -1)
1131 self.checkequal(True, 'hello', 'endswith', ('hell', 'ell'), 0, -1)
1150 self.checkequal('c', 'abc', '__getitem__', -1)
1175 indices = (0, None, 1, 3, 41, sys.maxsize, -1, -2, -37)
1185 self.checkequal('', 'abc', '__mul__', -1)
1191 # XXX: on a 64-bit system, this doesn't raise an overflow error,
1209 self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
1211 self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
1241 for ordinal in (-100, 0x200000):
1287 SIZE_MAX = (1 << (PY_SSIZE_T_MAX.bit_length() + 1)) - 1
1308 # Check that strings don't copy and modify cached single-character strings
1314 self.checkequal('a', 'A', 'replace', 'A', 'a')
1360 self.checkequal(3, s, 'find', 'l', -2, None)
1361 self.checkequal(2, s, 'find', 'l', None, -2)
1365 self.checkequal(3, s, 'rfind', 'l', -2, None)
1366 self.checkequal(2, s, 'rfind', 'l', None, -2)
1370 self.checkequal(3, s, 'index', 'l', -2, None)
1371 self.checkequal(2, s, 'index', 'l', None, -2)
1375 self.checkequal(3, s, 'rindex', 'l', -2, None)
1376 self.checkequal(2, s, 'rindex', 'l', None, -2)
1380 self.checkequal(1, s, 'count', 'l', -2, None)
1381 self.checkequal(1, s, 'count', 'l', None, -2)
1385 self.checkequal(True, s, 'endswith', 'lo', -2, None)
1386 self.checkequal(True, s, 'endswith', 'l', None, -2)
1390 self.checkequal(True, s, 'startswith', 'l', -2, None)
1391 self.checkequal(True, s, 'startswith', 'h', None, -2)