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 5, 2018
1 parent b942c13 commit 3ef84f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
12 changes: 8 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ authors = ["ScottPJones <[email protected]>"]
keywords = ["Strings"]
license = "MIT"
uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a"
version = "0.1.10"
version = "0.1.11"

[deps]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

ModuleInterfaceTools = "5cb8414e-7aab-5a03-a681-351269c074bf"
Expand All @@ -18,3 +15,10 @@ MurmurHash3 = "b10b62ed-fbae-5ea5-b934-abaf0477b71d"

StrAPI = "69e7dfc3-c4d0-5e14-8d95-d6042a05b383"
ChrBase = "c13fa7b1-fb91-5a40-8b3c-3aad7fd30002"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[targets]
test = ["Test", "Random"]
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
23 changes: 23 additions & 0 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ 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)
# Don't do this for LatinStr until ChrBase bug fixed
ST !== LatinStr && @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 3ef84f7

Please sign in to comment.