Skip to content

Commit

Permalink
Add more unit tests for casefolding
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPJones committed Oct 4, 2018
1 parent b942c13 commit a2d9744
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/StrBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using ModuleInterfaceTools
_memcmp, _memcpy, _memset, _fwd_memchr, _rev_memchr,
empty_string, _calcpnt, _mask_bytes, _allocate,
MS_UTF8, MS_UTF16, MS_UTF32, MS_SubUTF32, MS_Latin, MS_ByteStr, MS_RawUTF8,
_wrap_substr, _empty_sub,
_wrap_substr, _empty_sub,
AccessType, UInt16_U, UInt32_U, UInt16_S, UInt32_S, UInt16_US, UInt32_US,
alignedtype, swappedtype, checkkeep, splitarr, __split, __rsplit, __replace

Expand Down
22 changes: 22 additions & 0 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ end
end
end

@testset "casefold string" begin
for ST in (ASCIIStr, LatinStr, UCS2Str, UTF32Str, UTF8Str, UTF16Str)
C = eltype(ST)
tm = typemax(C)
for c = 0:Int(tm)
# Skip surrogates
0xd800 <= c < 0xe000 && continue
ch = C(c)
# Check to make sure this character would still fit uppercased
cu = uppercase(ch)
cu > tm && continue
for str in ("$ch test Beg", "test End $ch", "test $ch Mid", "$ch")
cvtstr = convert(ST, str)
@test uppercase(str) == uppercase(cvtstr)
@test lowercase(str) == lowercase(cvtstr)
#@test titlecase(str) == titlecase(cvtstr)
#@test uppercase_first(str) == uppercase_first(cvtstr)
end
end
end
end

@testset "{starts,ends}_with" begin
for (ST, type_list) in compat_types, CT in type_list, str in test_strings_base[CT]
cvtstr = convert(ST, str)
Expand Down

0 comments on commit a2d9744

Please sign in to comment.