diff --git a/tests/engine/test_filter_macro_resolver.cpp b/tests/engine/test_filter_macro_resolver.cpp index b2b3ce06..20b5f114 100644 --- a/tests/engine/test_filter_macro_resolver.cpp +++ b/tests/engine/test_filter_macro_resolver.cpp @@ -20,27 +20,10 @@ limitations under the License. using namespace std; using namespace libsinsp::filter::ast; -static pos_info create_pos(uint32_t idx, uint32_t line, uint32_t col) -{ - pos_info ret; - ret.idx = idx; - ret.line = line; - ret.col = col; - - return ret; -} - -static bool operator==(const pos_info& p1, const pos_info& p2) -{ - return (p1.idx == p2.idx) && - (p1.line == p2.line) && - (p1.col == p2.col); -} - TEST_CASE("Should resolve macros on a filter AST", "[rule_loader]") { string macro_name = "test_macro"; - pos_info macro_pos = create_pos(12, 85, 27); + pos_info macro_pos(12, 85, 27); SECTION("in the general case") { @@ -109,8 +92,8 @@ TEST_CASE("Should resolve macros on a filter AST", "[rule_loader]") string a_macro_name = macro_name + "_1"; string b_macro_name = macro_name + "_2"; - pos_info a_macro_pos = create_pos(11, 75, 43); - pos_info b_macro_pos = create_pos(91, 21, 9); + pos_info a_macro_pos(11, 75, 43); + pos_info b_macro_pos(91, 21, 9); std::shared_ptr a_macro = std::move( unary_check_expr::create("one.field", "", "exists")); @@ -158,8 +141,8 @@ TEST_CASE("Should resolve macros on a filter AST", "[rule_loader]") string a_macro_name = macro_name + "_1"; string b_macro_name = macro_name + "_2"; - pos_info a_macro_pos = create_pos(47, 1, 76); - pos_info b_macro_pos = create_pos(111, 65, 2); + pos_info a_macro_pos(47, 1, 76); + pos_info b_macro_pos(111, 65, 2); std::vector> a_macro_and; a_macro_and.push_back(unary_check_expr::create("one.field", "", "exists")); @@ -208,7 +191,7 @@ TEST_CASE("Should resolve macros on a filter AST", "[rule_loader]") TEST_CASE("Should find unknown macros", "[rule_loader]") { string macro_name = "test_macro"; - pos_info macro_pos = create_pos(9, 4, 2); + pos_info macro_pos(9, 4, 2); SECTION("in the general case") { @@ -230,8 +213,8 @@ TEST_CASE("Should find unknown macros", "[rule_loader]") string a_macro_name = macro_name + "_1"; string b_macro_name = macro_name + "_2"; - pos_info a_macro_pos = create_pos(32, 84, 9); - pos_info b_macro_pos = create_pos(1, 0, 5); + pos_info a_macro_pos(32, 84, 9); + pos_info b_macro_pos(1, 0, 5); std::vector> a_macro_and; a_macro_and.push_back(unary_check_expr::create("one.field", "", "exists")); @@ -259,8 +242,8 @@ TEST_CASE("Should find unknown macros", "[rule_loader]") TEST_CASE("Should undefine macro", "[rule_loader]") { string macro_name = "test_macro"; - pos_info macro_pos_1 = create_pos(12, 9, 3); - pos_info macro_pos_2 = create_pos(9, 6, 3); + pos_info macro_pos_1(12, 9, 3); + pos_info macro_pos_2(9, 6, 3); std::shared_ptr macro = std::move(unary_check_expr::create("test.field", "", "exists")); std::shared_ptr a_filter = std::move(value_expr::create(macro_name, macro_pos_1)); @@ -287,7 +270,7 @@ TEST_CASE("Should undefine macro", "[rule_loader]") TEST_CASE("Should clone macro AST", "[rule_loader]") { string macro_name = "test_macro"; - pos_info macro_pos = create_pos(5, 2, 8888); + pos_info macro_pos(5, 2, 8888); std::shared_ptr macro = std::move(unary_check_expr::create("test.field", "", "exists")); std::shared_ptr filter = std::move(value_expr::create(macro_name, macro_pos)); filter_macro_resolver resolver;