diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5de31be8502855954d5bb7d9e037d6bb6dd30ae1..5b7ff6b0660b7076ebeb0cd9b7b7debf99462310 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -144,6 +144,7 @@ add_executable (unit_tests test_SmallVector.cpp test_Socket.cpp test_SocketModule.cpp + test_SourceLocation.cpp test_SquareGaussQuadrature.cpp test_SquareTransformation.cpp test_SymbolTable.cpp diff --git a/tests/test_SourceLocation.cpp b/tests/test_SourceLocation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f27a14b95381a67db840664796b7bd1067a6939d --- /dev/null +++ b/tests/test_SourceLocation.cpp @@ -0,0 +1,30 @@ +#include <catch2/catch_test_macros.hpp> +#include <catch2/matchers/catch_matchers_all.hpp> + +#include <utils/SourceLocation.hpp> + +// clazy:excludeall=non-pod-global-static + +TEST_CASE("SourceLocation", "[utils]") +{ + SECTION("provided") + { + SourceLocation source_location("filename", 3, 2, "function_name"); + + REQUIRE(source_location.filename() == "filename"); + REQUIRE(source_location.line() == 3); + REQUIRE(source_location.column() == 2); + REQUIRE(source_location.function() == "function_name"); + } + + SECTION("from std::source_location") + { + auto std_source_location = std::experimental::source_location::current(); + SourceLocation source_location(std_source_location); + + REQUIRE(source_location.filename() == std_source_location.file_name()); + REQUIRE(source_location.line() == std_source_location.line()); + REQUIRE(source_location.column() == std_source_location.column()); + REQUIRE(source_location.function() == std_source_location.function_name()); + } +}