Make sure that floating point values are serialized properly in YAML; #363 (#370)

This commit is contained in:
Dr. Patrick Urbanke (劉自成)
2025-03-01 14:51:46 +08:00
committed by GitHub
parent e6a262342b
commit 37dbcef95a
2 changed files with 40 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
#include <iostream>
#include <rfl.hpp>
#include <string>
#include <vector>
#include "write_and_read.hpp"
namespace test_double {
TEST(yaml, test_double) {
auto obj = rfl::Generic::Object();
const double age = 10;
obj["age"] = age;
const auto s = rfl::yaml::write(obj);
EXPECT_EQ(
rfl::from_generic<double>(
rfl::yaml::read<rfl::Generic::Object>(s).value().get("age").value())
.value(),
10.0);
}
} // namespace test_double