// @requires-reflection #include #include #include #include namespace { struct Rec { std::string name = ""; int age = 0; double score = 0; bool ok = false; }; } // namespace // @tag reflection Void::Testing::Test csv_header_and_to_row() { const auto h = Void::Csv::header_row(); Void::Testing::expect_eq(h.size(), std::size_t{4}); Void::Testing::expect(h[0] == "name" && h[1] == "age" && h[3] == "ok"); Rec r{"neo", 30, 9.5, true}; const auto row = Void::Csv::to_row(r); Void::Testing::expect(row[0] == "neo" && row[1] == "30" && row[3] == "true"); } // @tag reflection Void::Testing::Test csv_from_row_round_trip() { Rec r{"trin", 28, 7.25, false}; const auto back = Void::Csv::from_row(Void::Csv::to_row(r)); Void::Testing::expect(back.has_value()); Void::Testing::expect_eq(back->name, std::string{"trin"}); Void::Testing::expect_eq(back->age, 28); Void::Testing::expect(back->score > 7.2 && back->score < 7.3); Void::Testing::expect_eq(back->ok, false); }