<commit_before>-module(tests).

-include_lib("eunit/include/eunit.hrl").
-compile(export_all).

application_start_test_() ->
    [ ?_assertEqual({ok, [p1_utils, stringprep]},
                    application:ensure_all_started(stringprep)),
      ?_assertEqual(ok, stringprep:start()) ].

application_start_stop_start_test_() ->
    [ ?_assertEqual({ok, []},
                    application:ensure_all_started(stringprep)),
      ?_assertEqual(ok, application:stop(stringprep)),
      ?_assertEqual(ok, stringprep:start()) ].

badarg_test() ->
    ?assertError(badarg, stringprep:nodeprep(foo)),
    ?assertError(badarg, stringprep:nameprep(123)),
    ?assertError(badarg, stringprep:resourceprep({foo, bar})),
    ?assertError(badarg, stringprep:tolower(fun() -> ok end)).

empty_string_test() ->
    ?assertEqual(<<>>, stringprep:nodeprep(<<>>)),
    ?assertEqual(<<>>, stringprep:nameprep(<<>>)),
    ?assertEqual(<<>>, stringprep:resourceprep(<<>>)),
    ?assertEqual(<<>>, stringprep:tolower(<<>>)).

'@_nodeprep_test'() ->
    ?assertEqual(error, stringprep:nodeprep(<<"@">>)).

tolower_test() ->
    ?assertEqual(<<"abcd">>, stringprep:tolower(<<"AbCd">>)).

resourceprep_test() ->
    ?assertEqual(
       <<95,194,183,194,176,226,137,136,88,46,209,130,208,189,206,<commit_msg>Make start test more robust<commit_after>-module(tests).

-include_lib("eunit/include/eunit.hrl").
-compile(export_all).

application_start_test_() ->
    [ ?_assertMatch({ok, _},
                    application:ensure_all_started(stringprep)),
      ?_assertEqual(ok, stringprep:start()) ].

application_start_stop_start_test_() ->
    [ ?_assertEqual({ok, []},
                    application:ensure_all_started(stringprep)),
      ?_assertEqual(ok, application:stop(stringprep)),
      ?_assertEqual(ok, stringprep:start()) ].

badarg_test() ->
    ?assertError(badarg, stringprep:nodeprep(foo)),
    ?assertError(badarg, stringprep:nameprep(123)),
    ?assertError(badarg, stringprep:resourceprep({foo, bar})),
    ?assertError(badarg, stringprep:tolower(fun() -> ok end)).

empty_string_test() ->
    ?assertEqual(<<>>, stringprep:nodeprep(<<>>)),
    ?assertEqual(<<>>, stringprep:nameprep(<<>>)),
    ?assertEqual(<<>>, stringprep:resourceprep(<<>>)),
    ?assertEqual(<<>>, stringprep:tolower(<<>>)).

'@_nodeprep_test'() ->
    ?assertEqual(error, stringprep:nodeprep(<<"@">>)).

tolower_test() ->
    ?assertEqual(<<"abcd">>, stringprep:tolower(<<"AbCd">>)).

resourceprep_test() ->
    ?assertEqual(
       <<95,194,183,194,176,226,137,136,88,46,209,130,208,189,206,
{'fraction_non_alphanumeric': 0.20421710269426005, 'fraction_numerical': 0.03553299492385787, 'mean_word_length': 5.1291866028708135, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6109280', 'n_tokens_mistral': 981, 'n_tokens_neox': 863, 'n_words': 95}