Files
Library/tests/standalone/Containers/Debug.cpp
T

38 lines
854 B
C++

#include <Void/Containers/Debug.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
#include <string>
#include <vector>
namespace
{
struct P {
int x;
int y;
};
} // namespace
// @tag reflection
Void::Testing::Test debug_dump_reflects_struct_elements()
{
#if !VOID_HAS_CXX26_REFLECTION
Void::Testing::skip("C++26 reflection is not available");
#else
std::vector<P> v{{1, 2}, {3, 4}};
Void::Testing::expect_eq(Void::Containers::debug_dump(v),
std::string{"[P{x: 1, y: 2}, P{x: 3, y: 4}]"});
#endif
}
// @tag reflection
Void::Testing::Test debug_dump_handles_scalars()
{
std::vector<int> n{1, 2, 3};
Void::Testing::expect_eq(Void::Containers::debug_dump(n),
std::string{"[1, 2, 3]"});
std::vector<int> empty;
Void::Testing::expect_eq(Void::Containers::debug_dump(empty),
std::string{"[]"});
}