test(topicidx): increase test coverage
This commit is contained in:
parent
fd0986071c
commit
9a249e4b01
|
@ -141,6 +141,7 @@ t_match_fast_forward(_) ->
|
||||||
% dbg:tracer(),
|
% dbg:tracer(),
|
||||||
% dbg:p(all, c),
|
% dbg:p(all, c),
|
||||||
% dbg:tpl({ets, next, '_'}, x),
|
% dbg:tpl({ets, next, '_'}, x),
|
||||||
|
?assertEqual(id1, id(match(<<"a/b/1/2/3/4/5/6/7/8/9/0">>, Tab))),
|
||||||
?assertEqual([id1], [id(M) || M <- matches(<<"a/b/1/2/3/4/5/6/7/8/9/0">>, Tab)]).
|
?assertEqual([id1], [id(M) || M <- matches(<<"a/b/1/2/3/4/5/6/7/8/9/0">>, Tab)]).
|
||||||
|
|
||||||
t_match_unique(_) ->
|
t_match_unique(_) ->
|
||||||
|
@ -180,14 +181,15 @@ t_match_wildcard_edge_cases(_) ->
|
||||||
F = fun({Topics, TopicName, Expected}) ->
|
F = fun({Topics, TopicName, Expected}) ->
|
||||||
Tab = emqx_topic_index:new(),
|
Tab = emqx_topic_index:new(),
|
||||||
_ = [emqx_topic_index:insert(T, N, <<>>, Tab) || {N, T} <- lists:enumerate(Topics)],
|
_ = [emqx_topic_index:insert(T, N, <<>>, Tab) || {N, T} <- lists:enumerate(Topics)],
|
||||||
Results = [id(M) || M <- emqx_topic_index:matches(TopicName, Tab, [unique])],
|
?assertEqual(
|
||||||
|
lists:last(Expected),
|
||||||
|
id(emqx_topic_index:match(TopicName, Tab)),
|
||||||
|
#{"Base topics" => Topics, "Topic name" => TopicName}
|
||||||
|
),
|
||||||
?assertEqual(
|
?assertEqual(
|
||||||
Expected,
|
Expected,
|
||||||
Results,
|
[id(M) || M <- emqx_topic_index:matches(TopicName, Tab, [unique])],
|
||||||
#{
|
#{"Base topics" => Topics, "Topic name" => TopicName}
|
||||||
"Base topics" => Topics,
|
|
||||||
"Topic name" => TopicName
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
end,
|
end,
|
||||||
lists:foreach(F, Datasets).
|
lists:foreach(F, Datasets).
|
||||||
|
|
Loading…
Reference in New Issue