Skip to content

Commit 1998481

Browse files
BodigrimLysxia
authored andcommitted
Test that case conversions are idempotent
1 parent 6c74f4c commit 1998481

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/Tests/Properties/Text.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ t_toTitle_1stNotLower = and . notLow . T.toTitle . T.filter stable . T.filter (n
128128
-- https://en.wikipedia.org/wiki/Georgian_Extended
129129
isGeorgian c = c >= '\4256' && c < '\4352'
130130

131+
t_toUpper_idempotent t = T.toUpper (T.toUpper t) === T.toUpper t
132+
t_toLower_idempotent t = T.toLower (T.toLower t) === T.toLower t
133+
t_toTitle_idempotent t = T.toTitle (T.toTitle t) === T.toTitle t
134+
t_toCaseFold_idempotent t = T.toCaseFold (T.toCaseFold t) === T.toCaseFold t
135+
131136
ascii_toLower (ASCIIString xs) = map C.toLower xs === T.unpack (T.toLower (T.pack xs))
132137
ascii_toUpper (ASCIIString xs) = map C.toUpper xs === T.unpack (T.toUpper (T.pack xs))
133138
ascii_toCaseFold (ASCIIString xs) = map C.toLower xs === T.unpack (T.toCaseFold (T.pack xs))
@@ -331,6 +336,10 @@ testText =
331336
testProperty "tl_toUpper_upper" tl_toUpper_upper,
332337
testProperty "t_toTitle_title" t_toTitle_title,
333338
testProperty "t_toTitle_1stNotLower" t_toTitle_1stNotLower,
339+
testProperty "t_toUpper_idempotent" t_toUpper_idempotent,
340+
testProperty "t_toLower_idempotent" t_toLower_idempotent,
341+
testProperty "t_toTitle_idempotent" t_toTitle_idempotent,
342+
testProperty "t_toCaseFold_idempotent" t_toCaseFold_idempotent,
334343
testProperty "ascii_toLower" ascii_toLower,
335344
testProperty "ascii_toUpper" ascii_toUpper,
336345
testProperty "ascii_toTitle" ascii_toTitle,

0 commit comments

Comments
 (0)