1 parent
f0825fbd1a
commit
42268c6c35
45 files changed
+2732
-262
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
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()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// 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\""});
|
||||
}
|
||||
Reference in new issue
Block a user