forked from for-GET/jesse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjesse_lib_tests.erl
51 lines (47 loc) · 1.69 KB
/
jesse_lib_tests.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%% @author Nicholas Lundgaard <[email protected]>
%% @doc EUnit tests for jesse_lib.
-module(jesse_lib_tests).
-include_lib("eunit/include/eunit.hrl").
re_run_default_test_() ->
{setup,
fun() ->
application:load(jesse)
end,
fun(_) ->
application:unload(jesse)
end,
[
{"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",
?_assertEqual(match,
jesse_lib:re_run(<<"123"/utf8>>, "^\\d+$"))},
{"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",
?_assertEqual(match,
jesse_lib:re_run(<<"3๓३"/utf8>>, "^\\d+$"))}
]}.
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'",
?_assertEqual(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+$"))}
]}.