diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-23 07:08:18 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2024-02-23 07:08:18 +0100 |
commit | 5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e (patch) | |
tree | 982ca2e7f9ac4e8c350dfb5c4f60bcfdfff5afaf /learn-you-some-erlang/tests/fifo_tests.erl | |
parent | 05ae56e5e89abf2993f84e6d52b250131f247c35 (diff) | |
download | erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.gz erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.bz2 erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.tar.xz erlang-workshop-5a9cdd3cc89507d4d74f8bded56ce5e037b3b56e.zip |
wip
Diffstat (limited to 'learn-you-some-erlang/tests/fifo_tests.erl')
-rw-r--r-- | learn-you-some-erlang/tests/fifo_tests.erl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/learn-you-some-erlang/tests/fifo_tests.erl b/learn-you-some-erlang/tests/fifo_tests.erl new file mode 100644 index 0000000..1252a1b --- /dev/null +++ b/learn-you-some-erlang/tests/fifo_tests.erl @@ -0,0 +1,22 @@ +-module(fifo_tests). +-include_lib("eunit/include/eunit.hrl"). + +new_test() -> ?assertEqual({fifo,[],[]}, fifo:new()). + +push_test_() -> + [?_assertEqual({fifo,[1,3],[2,4]}, fifo:push({fifo,[3],[2,4]},1)), + ?_assertEqual({fifo,[2],[]}, fifo:push({fifo,[],[]},2))]. + +pop_test_() -> + [?_assertEqual({3,{fifo,[],[2]}}, fifo:pop({fifo,[],[3,2]})), + ?_assertEqual({3,{fifo,[],[2]}}, fifo:pop({fifo,[2,3],[]})), + ?_assertEqual({3,{fifo,[2,1],[]}},fifo:pop({fifo,[2,1],[3]})), + ?_assertEqual({1,{fifo,[],[2,3]}}, + fifo:pop(fifo:push(fifo:push(fifo:push(fifo:new(),1),2),3))), + ?_assertError('empty fifo', fifo:pop({fifo,[],[]}))]. + +empty_test_() -> + [?_assertEqual(true, fifo:empty(fifo:new())), + ?_assertEqual(false, fifo:empty({fifo,[1],[]})), + ?_assertEqual(false, fifo:empty({fifo,[],[1]})), + ?_assertEqual(false, fifo:empty({fifo,[1],[2]}))]. |