Skip to content

Commit 401686d

Browse files
committed
Add more unit tests for casefolding
1 parent d6bc053 commit 401686d

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

Project.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ authors = ["ScottPJones <[email protected]>"]
44
keywords = ["Strings"]
55
license = "MIT"
66
uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a"
7-
version = "0.1.10"
7+
version = "0.1.11"
88

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

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

1916
StrAPI = "69e7dfc3-c4d0-5e14-8d95-d6042a05b383"
2017
ChrBase = "c13fa7b1-fb91-5a40-8b3c-3aad7fd30002"
18+
19+
[extras]
20+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
21+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
22+
23+
[targets]
24+
test = ["Test", "Random"]

src/StrBase.jl

Lines changed: 1 addition & 1 deletion
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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,29 @@ 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+
# Don't do this for LatinStr until ChrBase bug fixed
51+
ST !== LatinStr && @test uppercase(str) == uppercase(cvtstr)
52+
@test lowercase(str) == lowercase(cvtstr)
53+
#@test titlecase(str) == titlecase(cvtstr)
54+
#@test uppercase_first(str) == uppercase_first(cvtstr)
55+
end
56+
end
57+
end
58+
end
59+
3760
@testset "{starts,ends}_with" begin
3861
for (ST, type_list) in compat_types, CT in type_list, str in test_strings_base[CT]
3962
cvtstr = convert(ST, str)

0 commit comments

Comments
 (0)