Coverage Tests

Add nonsense tests for nonsense coverage on standard methods.

Look at CDB search_hash_table - looks like it doubled-up on break-outs
so that one would never get hit
This commit is contained in:
martinsumner 2016-11-08 01:03:09 +00:00
parent b43ec0de7e
commit 8b8652e2d7
2 changed files with 22 additions and 4 deletions

View file

@ -1098,9 +1098,9 @@ search_hash_table(Handle, [Entry|RestOfEntries], Hash, Key, QuickCheck) ->
_ ->
KV
end;
0 ->
% Hash is 0 so key must be missing as 0 found before Hash matched
missing;
%0 ->
% % Hash is 0 so key must be missing as 0 found before Hash matched
% missing;
_ ->
search_hash_table(Handle, RestOfEntries, Hash, Key, QuickCheck)
end.
@ -1841,4 +1841,15 @@ corrupt_testfile_at_offset(Offset) ->
?assertMatch({"Key100", "Value100"}, cdb_get(P2, "Key100")),
ok = cdb_close(P2).
nonsense_coverage_test() ->
{ok, Pid} = gen_fsm:start(?MODULE, [#cdb_options{}], []),
ok = gen_fsm:send_all_state_event(Pid, nonsense),
?assertMatch({next_state, reader, #state{}}, handle_info(nonsense,
reader,
#state{})),
?assertMatch({ok, reader, #state{}}, code_change(nonsense,
reader,
#state{},
nonsense)).
-endif.

View file

@ -2026,6 +2026,13 @@ filename_test() ->
nonsense_coverage_test() ->
{ok, Pid} = gen_fsm:start(?MODULE, [], []),
undefined = gen_fsm:sync_send_all_state_event(Pid, nonsense),
ok = gen_fsm:send_all_state_event(Pid, nonsense).
ok = gen_fsm:send_all_state_event(Pid, nonsense),
?assertMatch({next_state, reader, #state{}}, handle_info(nonsense,
reader,
#state{})),
?assertMatch({ok, reader, #state{}}, code_change(nonsense,
reader,
#state{},
nonsense)).
-endif.