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<T>::digits10
is not being used correctly.
This commit is contained in:
Simon Gene Gottlieb 2018-12-11 22:18:36 +01:00
parent f2608bf2f1
commit b6b521fccb

View File

@ -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<float>());
}
TEST(NodeTest, FloatingPrecisionDouble) {
const double x = 0.123456789;
Node node = Node(x);
EXPECT_EQ(x, node.as<double>());