From f8acd752e340a2e6a5e3c6005ae1648be4af9bca Mon Sep 17 00:00:00 2001 From: Piotr Sokolowski Date: Thu, 16 Jan 2020 16:28:57 +0100 Subject: [PATCH] #308 Added unit test for testing behaviour of filter compilation for ['*'] case --- src/imem_snap.erl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/imem_snap.erl b/src/imem_snap.erl index 7ffdedb..66b90c7 100755 --- a/src/imem_snap.erl +++ b/src/imem_snap.erl @@ -1452,6 +1452,42 @@ f2mc_test_() -> ] }. +filters2ms_test_() -> + { + inparallel, + [{ + lists:flatten(io_lib:format("~s : ~p", [Title, Filter])), + fun() -> + case catch filters2ms(true,Filter) of + {'EXIT', Exception} -> + ?debugFmt( + "~n~s : imem_snap:filters2ms(true,~p).~n" + "Expected : ~p~n" + "Exception : ~p", + [Title, Filter, MatchSpec, Exception] + ), + error(failed); + CalculatedMs -> + if CalculatedMs /= MatchSpec -> + ?debugFmt( + "~n~s : imem_snap:filters2ms(~p, '$1').~n" + "Expected : ~p~n" + "Got : ~p", + [Title, Filter, MatchSpec, CalculatedMs] + ); + true -> ok + end, + ?assertEqual(MatchSpec, CalculatedMs) + end + end + } || {Title, Filter, MatchSpec} <- [ + {"all", ['*'], [{#{ckey => '$1'},[],['$_']}]}, + {"list all", [['*']], [{#{ckey => '$1'},[{is_list,'$1'}],['$_']}] }, + {"all tuple", [{'*'}], [{#{ckey => '$1'},[{is_tuple,'$1'}],['$_']}]} + ] + ] + }. + msrun_test_() -> Rows = [ ["a"],