9999end
100100
101101@testset " issue #7248" begin
102- @test_throws BoundsError length (" hello" , 1 , - 1 ) == 0
103- @test prevind (" hello" , 0 , 1 ) == - 1
104- @test_throws BoundsError length (" hellø" , 1 , - 1 ) == 0
105- @test prevind (" hellø" , 0 , 1 ) == - 1
106- @test_throws BoundsError length (" hello" , 1 , 10 ) == 10
102+ @test_throws BoundsError length (" hello" , 1 , - 1 )
103+ @test_throws BoundsError prevind (" hello" , 0 , 1 )
104+ @test_throws BoundsError length (" hellø" , 1 , - 1 )
105+ @test_throws BoundsError prevind (" hellø" , 0 , 1 )
106+ @test_throws BoundsError length (" hello" , 1 , 10 )
107107 @test nextind (" hello" , 0 , 10 ) == 10
108108 @test_throws BoundsError length (" hellø" , 1 , 10 ) == 9
109109 @test nextind (" hellø" , 0 , 10 ) == 11
579579 SubString (" 123∀α>β:α+1>β123" , 4 , 18 ),
580580 SubString (s " 123∀α>β:α+1>β123" , 4 , 18 )]
581581 for s in strs
582- @test thisind (s, - 2 ) == - 2
582+ @test_throws BoundsError thisind (s, - 2 )
583+ @test_throws BoundsError thisind (s, - 1 )
583584 @test thisind (s, 0 ) == 0
584585 @test thisind (s, 1 ) == 1
585586 @test thisind (s, 2 ) == 1
@@ -590,86 +591,97 @@ end
590591 @test thisind (s, 15 ) == 15
591592 @test thisind (s, 16 ) == 15
592593 @test thisind (s, 17 ) == 17
593- @test thisind (s, 30 ) == 30
594+ @test_throws BoundsError thisind (s, 18 )
595+ @test_throws BoundsError thisind (s, 19 )
594596 end
595597 end
596598
597599 let strs = Any[" " , s "" , SubString (" 123" , 2 , 1 ), SubString (s " 123" , 2 , 1 )]
598- for s in strs, i in - 2 : 2
599- @test thisind (s, i) == i
600+ for s in strs
601+ @test_throws BoundsError thisind (s, - 1 )
602+ @test thisind (s, 0 ) == 0
603+ @test thisind (s, 1 ) == 1
604+ @test_throws BoundsError thisind (s, 2 )
600605 end
601606 end
602607end
603608
604609@testset " prevind and nextind" begin
605- let strs = Any[" ∀α>β:α+1>β" , GenericString (" ∀α>β:α+1>β" )]
606- for i in 1 : 2
607- @test prevind (strs[i], 1 ) == 0
608- @test prevind (strs[i], 1 , 1 ) == 0
609- @test prevind (strs[i], 2 ) == 1
610- @test prevind (strs[i], 2 , 1 ) == 1
611- @test prevind (strs[i], 4 ) == 1
612- @test prevind (strs[i], 4 , 1 ) == 1
613- @test prevind (strs[i], 5 ) == 4
614- @test prevind (strs[i], 5 , 1 ) == 4
615- @test prevind (strs[i], 5 , 2 ) == 1
616- @test prevind (strs[i], 5 , 3 ) == 0
617- @test prevind (strs[i], 15 ) == 14
618- @test prevind (strs[i], 15 , 1 ) == 14
619- @test prevind (strs[i], 15 , 2 ) == 13
620- @test prevind (strs[i], 15 , 3 ) == 12
621- @test prevind (strs[i], 15 , 4 ) == 10
622- @test prevind (strs[i], 15 , 10 ) == 0
623- @test prevind (strs[i], 15 , 9 ) == 1
624- @test prevind (strs[i], 16 ) == 15
625- @test prevind (strs[i], 16 , 1 ) == 15
626- @test prevind (strs[i], 16 , 2 ) == 14
627- @test prevind (strs[i], 20 ) == 19
628- @test prevind (strs[i], 20 , 1 ) == 19
629- @test prevind (strs[i], 20 , 10 ) == 7
630- @test prevind (strs[i], 20 , 0 ) == 20
631-
632- @test nextind (strs[i], - 1 ) == 0
633- @test nextind (strs[i], - 1 , 1 ) == 0
634- @test nextind (strs[i], - 1 , 2 ) == 1
635- @test nextind (strs[i], - 1 , 3 ) == 4
636- @test nextind (strs[i], 0 , 2 ) == 4
637- @test nextind (strs[i], 0 , 20 ) == 26
638- @test nextind (strs[i], 0 , 10 ) == 15
639- @test nextind (strs[i], 1 ) == 4
640- @test nextind (strs[i], 1 , 1 ) == 4
641- @test nextind (strs[i], 1 , 2 ) == 6
642- @test nextind (strs[i], 1 , 9 ) == 15
643- @test nextind (strs[i], 1 , 10 ) == 17
644- @test nextind (strs[i], 2 ) == 4
645- @test nextind (strs[i], 2 , 1 ) == 4
646- @test nextind (strs[i], 3 ) == 4
647- @test nextind (strs[i], 3 , 1 ) == 4
648- @test nextind (strs[i], 4 ) == 6
649- @test nextind (strs[i], 4 , 1 ) == 6
650- @test nextind (strs[i], 14 ) == 15
651- @test nextind (strs[i], 14 , 1 ) == 15
652- @test nextind (strs[i], 15 ) == 17
653- @test nextind (strs[i], 15 , 1 ) == 17
654- @test nextind (strs[i], 20 ) == 21
655- @test nextind (strs[i], 20 , 1 ) == 21
656- @test nextind (strs[i], 20 , 0 ) == 20
657-
658- for x in - 10 : 20
659- n = p = x
660- for j in 1 : 40
661- p = prevind (strs[i], p)
662- @test prevind (strs[i], x, j) == p
663- n = nextind (strs[i], n)
664- @test nextind (strs[i], x, j) == n
610+ for s in Any[" ∀α>β:α+1>β" , GenericString (" ∀α>β:α+1>β" )]
611+ @test_throws BoundsError prevind (s, 0 )
612+ @test_throws BoundsError prevind (s, 0 , 0 )
613+ @test_throws BoundsError prevind (s, 0 , 1 )
614+ @test prevind (s, 1 ) == 0
615+ @test prevind (s, 1 , 1 ) == 0
616+ @test prevind (s, 1 , 0 ) == 1
617+ @test prevind (s, 2 ) == 1
618+ @test prevind (s, 2 , 1 ) == 1
619+ @test prevind (s, 4 ) == 1
620+ @test prevind (s, 4 , 1 ) == 1
621+ @test prevind (s, 5 ) == 4
622+ @test prevind (s, 5 , 1 ) == 4
623+ @test prevind (s, 5 , 2 ) == 1
624+ @test prevind (s, 5 , 3 ) == 0
625+ @test prevind (s, 15 ) == 14
626+ @test prevind (s, 15 , 1 ) == 14
627+ @test prevind (s, 15 , 2 ) == 13
628+ @test prevind (s, 15 , 3 ) == 12
629+ @test prevind (s, 15 , 4 ) == 10
630+ @test prevind (s, 15 , 10 ) == 0
631+ @test prevind (s, 15 , 9 ) == 1
632+ @test prevind (s, 16 ) == 15
633+ @test prevind (s, 16 , 1 ) == 15
634+ @test prevind (s, 16 , 2 ) == 14
635+ @test prevind (s, 17 ) == 15
636+ @test prevind (s, 17 , 1 ) == 15
637+ @test prevind (s, 17 , 2 ) == 14
638+ @test_throws BoundsError prevind (s, 18 )
639+ @test_throws BoundsError prevind (s, 18 , 0 )
640+ @test_throws BoundsError prevind (s, 18 , 1 )
641+
642+ @test_throws BoundsError nextind (s, - 1 )
643+ @test_throws BoundsError nextind (s, - 1 , 0 )
644+ @test_throws BoundsError nextind (s, - 1 , 1 )
645+ @test nextind (s, 0 , 2 ) == 4
646+ @test nextind (s, 0 , 20 ) == 26
647+ @test nextind (s, 0 , 10 ) == 15
648+ @test nextind (s, 1 ) == 4
649+ @test nextind (s, 1 , 1 ) == 4
650+ @test nextind (s, 1 , 2 ) == 6
651+ @test nextind (s, 1 , 9 ) == 15
652+ @test nextind (s, 1 , 10 ) == 17
653+ @test nextind (s, 2 ) == 4
654+ @test nextind (s, 2 , 1 ) == 4
655+ @test nextind (s, 3 ) == 4
656+ @test nextind (s, 3 , 1 ) == 4
657+ @test nextind (s, 4 ) == 6
658+ @test nextind (s, 4 , 1 ) == 6
659+ @test nextind (s, 14 ) == 15
660+ @test nextind (s, 14 , 1 ) == 15
661+ @test nextind (s, 15 ) == 17
662+ @test nextind (s, 15 , 1 ) == 17
663+ @test nextind (s, 15 , 2 ) == 18
664+ @test nextind (s, 16 ) == 17
665+ @test nextind (s, 16 , 1 ) == 17
666+ @test nextind (s, 16 , 2 ) == 18
667+ @test nextind (s, 16 , 3 ) == 19
668+ @test_throws BoundsError nextind (s, 17 )
669+ @test_throws BoundsError nextind (s, 17 , 0 )
670+ @test_throws BoundsError nextind (s, 17 , 1 )
671+
672+ for x in 0 : ncodeunits (s)+ 1
673+ n = p = x
674+ for j in 1 : 40
675+ if 1 ≤ p
676+ p = prevind (s, p)
677+ @test prevind (s, x, j) == p
678+ end
679+ if n ≤ ncodeunits (s)
680+ n = nextind (s, n)
681+ @test nextind (s, x, j) == n
665682 end
666683 end
667684 end
668- @test prevind (strs[1 ], - 1 ) == - 2
669- @test prevind (strs[1 ], - 1 , 1 ) == - 2
670-
671- @test prevind (strs[2 ], - 1 ) == - 2
672- @test prevind (strs[2 ], - 1 , 1 ) == - 2
673685 end
674686end
675687
0 commit comments