From 0e544547acefd8bd422e03c05059fc937fcb4e74 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Sun, 10 Nov 2024 22:41:39 +0100 Subject: [PATCH] Add missing tests for ASTCheckpoint --- tests/CMakeLists.txt | 1 + tests/test_ASTCheckpoint.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/test_ASTCheckpoint.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ccb5a927..8fd49bde4 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 000000000..85f0a5c90 --- /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); +} -- GitLab