56 lines
1.6 KiB
Erlang
56 lines
1.6 KiB
Erlang
%%%-------------------------------------------------------------------
|
|
%%% @author ivan
|
|
%%% @copyright (C) 2023, self
|
|
%%% @doc
|
|
%%%
|
|
%%% @end
|
|
%%% Created : 09. Feb 2023 23:52
|
|
%%%-------------------------------------------------------------------
|
|
-module(fib_test).
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
fib_test_() -> [
|
|
{"Test fib_p", fun test_fib_p/0 },
|
|
{"Test fib_g", fun test_fib_g/0 },
|
|
{"Test tail_fib", fun test_tail_fib/0 }
|
|
].
|
|
|
|
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)).
|
|
|
|
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)).
|
|
|
|
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)).
|