From b6b521fccb73b1fc1b7d58639cba8d96dd5aca39 Mon Sep 17 00:00:00 2001 From: Simon Gene Gottlieb Date: Tue, 11 Dec 2018 22:18:36 +0100 Subject: [PATCH] add unittest for YAML::Node <-> float This adds a unittests which stores a 'float' into a Node and than extract it again. A version for 'double' already exists. Note: this unittest is failing, since std::numeric_limits::digits10 is not being used correctly. --- test/node/node_test.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/node/node_test.cpp b/test/node/node_test.cpp index ccb6df1..18234db 100644 --- a/test/node/node_test.cpp +++ b/test/node/node_test.cpp @@ -391,7 +391,13 @@ TEST(NodeTest, AutoBoolConversion) { EXPECT_TRUE(!!node["foo"]); } -TEST(NodeTest, FloatingPrecision) { +TEST(NodeTest, FloatingPrecisionFloat) { + const float x = 0.123456789; + Node node = Node(x); + EXPECT_EQ(x, node.as()); +} + +TEST(NodeTest, FloatingPrecisionDouble) { const double x = 0.123456789; Node node = Node(x); EXPECT_EQ(x, node.as());