Skip to content

Commit a2d9744

Browse files
committed
Add more unit tests for casefolding
1 parent b942c13 commit a2d9744

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/StrBase.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using ModuleInterfaceTools
3232
_memcmp, _memcpy, _memset, _fwd_memchr, _rev_memchr,
3333
empty_string, _calcpnt, _mask_bytes, _allocate,
3434
MS_UTF8, MS_UTF16, MS_UTF32, MS_SubUTF32, MS_Latin, MS_ByteStr, MS_RawUTF8,
35-
_wrap_substr, _empty_sub,
35+
_wrap_substr, _empty_sub,
3636
AccessType, UInt16_U, UInt32_U, UInt16_S, UInt32_S, UInt16_US, UInt32_US,
3737
alignedtype, swappedtype, checkkeep, splitarr, __split, __rsplit, __replace
3838

test/basic.jl

+22
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ end
3434
end
3535
end
3636

37+
@testset "casefold string" begin
38+
for ST in (ASCIIStr, LatinStr, UCS2Str, UTF32Str, UTF8Str, UTF16Str)
39+
C = eltype(ST)
40+
tm = typemax(C)
41+
for c = 0:Int(tm)
42+
# Skip surrogates
43+
0xd800 <= c < 0xe000 && continue
44+
ch = C(c)
45+
# Check to make sure this character would still fit uppercased
46+
cu = uppercase(ch)
47+
cu > tm && continue
48+
for str in ("$ch test Beg", "test End $ch", "test $ch Mid", "$ch")
49+
cvtstr = convert(ST, str)
50+
@test uppercase(str) == uppercase(cvtstr)
51+
@test lowercase(str) == lowercase(cvtstr)
52+
#@test titlecase(str) == titlecase(cvtstr)
53+
#@test uppercase_first(str) == uppercase_first(cvtstr)
54+
end
55+
end
56+
end
57+
end
58+
3759
@testset "{starts,ends}_with" begin
3860
for (ST, type_list) in compat_types, CT in type_list, str in test_strings_base[CT]
3961
cvtstr = convert(ST, str)

0 commit comments

Comments
 (0)