#include #include #include namespace { struct Point { int x; int y; }; bool operator==(const Point& a, const Point& b) { return a.x == b.x && a.y == b.y; } } // namespace // Sanity: equal structs pass. Void::Testing::Test struct_eq_passes_when_equal() { Void::Testing::expect_eq(Point{1, 2}, Point{1, 2}); } // The reflection-aware repr is exercised by Void::Result::Detail::repr; // we verify here that calling repr on a struct produces a string that // includes the type name and field values. Void::Testing::Test repr_renders_struct_via_reflection() { #if !VOID_HAS_CXX26_REFLECTION Void::Testing::skip("C++26 reflection is not available"); #else const auto out = Void::Testing::Detail::repr(Point{3, 4}); Void::Testing::expect(out.find("Point") != std::string::npos); Void::Testing::expect(out.find("x: 3") != std::string::npos); Void::Testing::expect(out.find("y: 4") != std::string::npos); #endif } // repr for primitives still works. Void::Testing::Test repr_handles_primitives() { Void::Testing::expect_eq(Void::Testing::Detail::repr(42), std::string{"42"}); Void::Testing::expect_eq(Void::Testing::Detail::repr(true), std::string{"true"}); Void::Testing::expect_eq(Void::Testing::Detail::repr(nullptr), std::string{"nullptr"}); Void::Testing::expect_eq(Void::Testing::Detail::repr(std::string{"hi"}), std::string{"\"hi\""}); }