erlang-labs/test/fib_test.erl

56 lines
1.6 KiB
Erlang
Raw Normal View History

%%%-------------------------------------------------------------------
%%% @author ivan
%%% @copyright (C) 2023, self
%%% @doc
%%%
%%% @end
%%% Created : 09. Feb 2023 23:52
%%%-------------------------------------------------------------------
-module(fib_test).
-include_lib("eunit/include/eunit.hrl").
2023-02-10 00:43:22 +03:00
fib_test_() -> [
2023-02-10 09:39:56 +03:00
{"Test fib_p", fun test_fib_p/0 },
2023-02-10 13:21:56 +03:00
{"Test fib_g", fun test_fib_g/0 },
{"Test tail_fib", fun test_tail_fib/0 }
2023-02-10 00:43:22 +03:00
].
test_fib_p() ->
?assertEqual(0, fib:fib_p(0)),
?assertEqual(1, fib:fib_p(1)),
?assertEqual(1, fib:fib_p(2)),
?assertEqual(2, fib:fib_p(3)),
?assertEqual(3, fib:fib_p(4)),
?assertEqual(5, fib:fib_p(5)),
?assertEqual(8, fib:fib_p(6)),
?assertEqual(13, fib:fib_p(7)),
?assertEqual(21, fib:fib_p(8)),
?assertEqual(34, fib:fib_p(9)),
?assertEqual(55, fib:fib_p(10)).
2023-02-10 09:39:56 +03:00
test_fib_g() ->
?assertEqual(0, fib:fib_g(0)),
?assertEqual(1, fib:fib_g(1)),
?assertEqual(1, fib:fib_g(2)),
?assertEqual(2, fib:fib_g(3)),
?assertEqual(3, fib:fib_g(4)),
?assertEqual(5, fib:fib_g(5)),
?assertEqual(8, fib:fib_g(6)),
?assertEqual(13, fib:fib_g(7)),
?assertEqual(21, fib:fib_g(8)),
?assertEqual(34, fib:fib_g(9)),
?assertEqual(55, fib:fib_g(10)).
2023-02-10 13:21:56 +03:00
test_tail_fib() ->
?assertEqual(0, fib:tail_fib(0)),
?assertEqual(1, fib:tail_fib(1)),
?assertEqual(1, fib:tail_fib(2)),
?assertEqual(2, fib:tail_fib(3)),
?assertEqual(3, fib:tail_fib(4)),
?assertEqual(5, fib:tail_fib(5)),
?assertEqual(8, fib:tail_fib(6)),
?assertEqual(13, fib:tail_fib(7)),
?assertEqual(21, fib:tail_fib(8)),
?assertEqual(34, fib:tail_fib(9)),
?assertEqual(55, fib:tail_fib(10)).