Skip to content
Snippets Groups Projects
Commit b63a6b2c authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for NaNHelper

parent 7e2d56e4
No related branches found
No related tags found
1 merge request!105Add NaNHelper utility
......@@ -85,6 +85,7 @@ add_executable (unit_tests
test_ListAffectationProcessor.cpp
test_MathModule.cpp
test_NameProcessor.cpp
test_NaNHelper.cpp
test_OStreamProcessor.cpp
test_ParseError.cpp
test_PETScUtils.cpp
......
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_all.hpp>
#include <utils/NaNHelper.hpp>
#include <sstream>
// clazy:excludeall=non-pod-global-static
TEST_CASE("NaNHelper", "[utils]")
{
SECTION("signaling NaN")
{
std::ostringstream ost_nan_helper;
ost_nan_helper << NaNHelper(std::numeric_limits<double>::signaling_NaN());
REQUIRE(ost_nan_helper.str() == "nan");
}
SECTION("valid double")
{
std::ostringstream ost_nan_helper;
ost_nan_helper << NaNHelper(double{3.2});
std::ostringstream ost;
ost << double{3.2};
REQUIRE(ost_nan_helper.str() == ost.str());
}
SECTION("non arithmetic type")
{
std::string s = "foo";
std::ostringstream ost_nan_helper;
ost_nan_helper << NaNHelper(s);
REQUIRE(ost_nan_helper.str() == s);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment