diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ccb5a9275b1be3dd7247372f334d83e67d7eeae..8fd49bde44783c6af4237747b78c26359769b3ba 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,6 +18,7 @@ add_executable (unit_tests test_Array.cpp test_ArraySubscriptProcessor.cpp test_ASTBuilder.cpp + test_ASTCheckpoint.cpp test_ASTDotPrinter.cpp test_ASTExecutionStack.cpp test_ASTModulesImporter.cpp diff --git a/tests/test_ASTCheckpoint.cpp b/tests/test_ASTCheckpoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..85f0a5c90b98ef9f04c5596ba12cd94ede03c6a7 --- /dev/null +++ b/tests/test_ASTCheckpoint.cpp @@ -0,0 +1,28 @@ +#include <catch2/catch_test_macros.hpp> +#include <catch2/matchers/catch_matchers_all.hpp> + +#include <language/ast/ASTNode.hpp> +#include <language/utils/ASTCheckpoint.hpp> + +// clazy:excludeall=non-pod-global-static + +TEST_CASE("ASTCheckpoint", "[language]") +{ + ASTNode ast_node; + + std::vector<size_t> location = {1, 2, 4}; + ASTCheckpoint cp{location, &ast_node}; + + REQUIRE(&cp.node() == &ast_node); + REQUIRE(cp.getASTLocation() == location); + + ASTCheckpoint cp_copy = cp; + + REQUIRE(&cp_copy.node() == &ast_node); + REQUIRE(cp_copy.getASTLocation() == location); + + ASTCheckpoint cp_move = std::move(cp); + + REQUIRE(&cp_move.node() == &ast_node); + REQUIRE(cp_move.getASTLocation() == location); +}