Skip to content

Commit

Permalink
More testsets for SubString and a few missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Sep 12, 2024
1 parent 71d237a commit 26189b1
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions test/strings/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@test convert(Union{String, SubString{String}}, u8str2) === u8str2
@test convert(Union{String, SubString{String}}, u8str2plain) === u8str2plain

for i1 = 1:length(u8str2)
for i1 = 1:ncodeunits(u8str2)
if !isvalid(u8str2, i1); continue; end
for i2 = i1:length(u8str2)
if !isvalid(u8str2, i2); continue; end
Expand Down Expand Up @@ -207,35 +207,34 @@
strs = ["∀∃∀"*String(rand(rng, UInt8, 40))*"∀∃∀",
String(rand(rng, UInt8, 50))]
@testset "proper nextind/prevind/thisind for SubString{String}: $(repr(s))" for s in strs
a = 0
while a <= ncodeunits(s)
a = nextind(s, a)
b = a - 1
while b <= ncodeunits(s)
ss = SubString(s, a:b)
s2 = s[a:b]
@test ncodeunits(ss) == ncodeunits(s2)
for i in 0:ncodeunits(ss)+1
@test thisind(ss, i) == thisind(s2, i)
end
for i in 0:ncodeunits(ss)
@test nextind(ss, i) == nextind(s2, i)
for j in 0:ncodeunits(ss)+5
if j > 0 || isvalid(ss, i)
@test nextind(ss, i, j) == nextind(s2, i, j)
end
a = 0
while a <= ncodeunits(s)
a = nextind(s, a)
b = a - 1
while b <= ncodeunits(s)
ss = SubString(s, a:b)
s2 = s[a:b]
@test ncodeunits(ss) == ncodeunits(s2)
for i in 0:ncodeunits(ss)+1
@test thisind(ss, i) == thisind(s2, i)
end
for i in 0:ncodeunits(ss)
@test nextind(ss, i) == nextind(s2, i)
for j in 0:ncodeunits(ss)+5
if j > 0 || isvalid(ss, i)
@test nextind(ss, i, j) == nextind(s2, i, j)
end
end
for i in 1:ncodeunits(ss)+1
@test prevind(ss, i) == prevind(s2, i)
for j in 0:ncodeunits(ss)+5
if j > 0 || isvalid(ss, i)
@test prevind(ss, i, j) == prevind(s2, i, j)
end
end
for i in 1:ncodeunits(ss)+1
@test prevind(ss, i) == prevind(s2, i)
for j in 0:ncodeunits(ss)+5
if j > 0 || isvalid(ss, i)
@test prevind(ss, i, j) == prevind(s2, i, j)
end
end
b = nextind(s, b)
end
b = nextind(s, b)
end
end
end
Expand Down

0 comments on commit 26189b1

Please sign in to comment.