Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions test/jesse_lib_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ re_run_default_test_() ->
application:unload(jesse)
end,
[
{"Support ISO Latin-1 letters in \w by default",
{"Support ISO Latin-1 letters in \\w by default",
?_assertEqual(match,
jesse_lib:re_run(<<"föø"/utf8>>, "^\\w+$"))},
{"Support ISO Latin-1 numbers in \d by default",
{"Support ISO Latin-1 numbers in \\d by default",
?_assertEqual(match,
jesse_lib:re_run(<<"123"/utf8>>, "^\\d+$"))},
{"Support beyond ISO Latin-1 letters in \w by default",
{"Support beyond ISO Latin-1 letters in \\w by default",
?_assertEqual(match,
jesse_lib:re_run(<<"fōô"/utf8>>, "^\\w+$"))},
{"Support beyond ISO Latin-1 numbers in \d by default",
{"Support beyond ISO Latin-1 numbers in \\d by default",
?_assertEqual(match,
jesse_lib:re_run(<<"3๓३"/utf8>>, "^\\d+$"))}
]}.

-if(defined(OTP_RELEASE) andalso ?OTP_RELEASE >= 28).
re_run_no_ucp_test_() ->
{setup,
fun() ->
Expand All @@ -36,16 +37,39 @@ re_run_no_ucp_test_() ->
end,
fun(_) -> application:unload(jesse) end,
[
{"Support ISO Latin-1 letters in \w without 'ucp'",
{"Do not support beyond ISO Latin-1 letters in \\w without 'ucp'",
?_assertEqual(nomatch,
jesse_lib:re_run(<<"föø"/utf8>>, "^\\w+$"))},
{"Do not support beyond ISO Latin-1 numbers in \\d without 'ucp'",
?_assertEqual(no match,
jesse_lib:re_run(<<"123"/utf8>>, "^\\d+$"))},
{"Do not support beyond ISO Latin-1 letters in \\w without 'ucp'",
?_assertEqual(nomatch,
jesse_lib:re_run(<<"fōô"/utf8>>, "^\\w+$"))},
{"Do not support beyond ISO Latin-1 numbers in \\d without 'ucp'",
?_assertEqual(nomatch,
jesse_lib:re_run(<<"3๓३"/utf8>>, "^\\d+$"))}
]}.
-else.
re_run_no_ucp_test_() ->
{setup,
fun() ->
application:load(jesse),
application:set_env(jesse, re_options, [unicode])
end,
fun(_) -> application:unload(jesse) end,
[
{"Support ISO Latin-1 letters in \\w without 'ucp'",
?_assertEqual(match,
jesse_lib:re_run(<<"föø"/utf8>>, "^\\w+$"))},
{"Support ISO Latin-1 numbers in \d without 'ucp'",
{"Support ISO Latin-1 numbers in \\d without 'ucp'",
?_assertEqual(match,
jesse_lib:re_run(<<"123"/utf8>>, "^\\d+$"))},
{"Do not support beyond ISO Latin-1 letters in \w without 'ucp'",
{"Do not support beyond ISO Latin-1 letters in \\w without 'ucp'",
?_assertEqual(nomatch,
jesse_lib:re_run(<<"fōô"/utf8>>, "^\\w+$"))},
{"Do not support beyond ISO Latin-1 numbers in \d without 'ucp'",
{"Do not support beyond ISO Latin-1 numbers in \\d without 'ucp'",
?_assertEqual(nomatch,
jesse_lib:re_run(<<"3๓३"/utf8>>, "^\\d+$"))}
]}.
-endif.
Loading