<commit_before>%%%----------------------------------------------------------------------
%%% File    : ticket_tests.erl
%%% Author  : <NAME> <<EMAIL>>
%%%           <NAME> <<EMAIL>>
%%% Description : ticket.erl unit tests
%%%
%%% Created : 25 Sep 2010 by <NAME> <<EMAIL>>
%%%----------------------------------------------------------------------

-module(ticket_tests).

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

%% Spec for auto-generated test/0 function (eunit).
-spec test() -> 'ok' | {'error', term()}.


-spec get_error_type_str_test() -> term().

get_error_type_str_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual("Assertion violation", ticket:get_error_type_str(Ticket)).

-spec get_error_descr_str1_test() -> term().

get_error_descr_str1_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(io_lib:format("~p.erl:~p: "
                               ++ "The expression '~s' evaluates to '~p' "
                               ++ "instead of '~p'~n"
                               ++ "Stack trace: ~p~n",
                               [mymodule, 42, "true =:= false", false, true,
                                []]),
                 ticket:get_error_descr_str(Ticket)).

-spec get_error_descr_str3_test() -> term().

get_error_descr_str3_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = exception,
    ErrorDescr = foobar,
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(io_lib:format("~p~n", [ErrorDescr]),
                 ticket:get_error_descr_str(Ticket)).

-spec get_target_test() -> term().

get_target_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(Target, ticket:get_target(Ticket)).

-spec get_state_test() -> term().

get_state_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(ErrorState, ticket:get_state(Ticket)).
<commit_msg>Add some ticket unit tests<commit_after>%%%----------------------------------------------------------------------
%%% File    : ticket_tests.erl
%%% Author  : <NAME> <<EMAIL>>
%%%           <NAME> <<EMAIL>>
%%% Description : ticket.erl unit tests
%%%
%%% Created : 25 Sep 2010 by <NAME> <<EMAIL>>
%%%----------------------------------------------------------------------

-module(ticket_tests).

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

%% Spec for auto-generated test/0 function (eunit).
-spec test() -> 'ok' | {'error', term()}.


-spec get_error_type_str_test() -> term().

get_error_type_str_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual("Assertion violation", ticket:get_error_type_str(Ticket)).

-spec get_error_descr_str1_test() -> term().

get_error_descr_str1_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(io_lib:format("~p.erl:~p: "
                               ++ "The expression '~s' evaluates to '~p' "
                               ++ "instead of '~p'~n"
                               ++ "Stack trace: ~p~n",
                               [mymodule, 42, "true =:= false", false, true,
                                []]),
                 ticket:get_error_descr_str(Ticket)).

-spec get_error_descr_str2_test() -> term().

get_error_descr_str2_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = deadlock,
    ErrorDescr = ["P1"],
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(io_lib:format("Process ~s blocks~n", ["P1"]),
                 ticket:get_error_descr_str(Ticket)).

-spec get_error_descr_str3_test() -> term().

get_error_descr_str3_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = deadlock,
    ErrorDescr = ["P1", "P1.1"],
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    Ps = io_lib:format("~s and ~s", ["P1", "P1.1"]),
    ?assertEqual(io_lib:format("Processes ~s block~n", [Ps]),
                 ticket:get_error_descr_str(Ticket)).

-spec get_error_descr_str4_test() -> term().

get_error_descr_str4_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = deadlock,
    ErrorDescr = ["P1", "P1.1", "P1.2"],
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    Ps = io_lib:format("~s, ~s and ~s", ["P1", "P1.1", "P1.2"]),
    ?assertEqual(io_lib:format("Processes ~s block~n", [Ps]),
                 ticket:get_error_descr_str(Ticket)).

-spec get_error_descr_str5_test() -> term().

get_error_descr_str5_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = exception,
    ErrorDescr = foobar,
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(io_lib:format("~p~n", [ErrorDescr]),
                 ticket:get_error_descr_str(Ticket)).

-spec get_target_test() -> term().

get_target_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(Target, ticket:get_target(Ticket)).

-spec get_state_test() -> term().

get_state_test() ->
    Target = {mymodule, myfunction, []},
    ErrorType = assert,
    ErrorDescr = {{assertion_violation, [{module, mymodule}, {line, 42},
                                         {expression, "true =:= false"},
                                         {expected, true}, {value, false}]},
                  []},
    Error = {ErrorType, ErrorDescr},
    ErrorState = state:empty(),
    Ticket = ticket:new(Target, Error, ErrorState),
    ?assertEqual(ErrorState, ticket:get_state(Ticket)).

{'fraction_non_alphanumeric': 0.1893441643770159, 'fraction_numerical': 0.00788436268068331, 'mean_word_length': 2.0621799561082663, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4475627', 'n_tokens_mistral': 2551, 'n_tokens_neox': 2476, 'n_words': 508}