Add test for adl begin/end
This commit is contained in:
parent
f7510c5930
commit
03bf57a69e
@ -65,6 +65,34 @@ TEST(ranges_test, format_set) {
|
|||||||
"{\"one\", \"two\"}");
|
"{\"one\", \"two\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace adl
|
||||||
|
{
|
||||||
|
struct box {
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto begin(box & b) noexcept -> int * {
|
||||||
|
return std::addressof(b.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto end(box & b) noexcept -> int * {
|
||||||
|
return std::addressof(b.value) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto begin(const box & b) noexcept -> const int * {
|
||||||
|
return std::addressof(b.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto end(const box & b) noexcept -> const int * {
|
||||||
|
return std::addressof(b.value) + 1;
|
||||||
|
}
|
||||||
|
} // namespace adl
|
||||||
|
|
||||||
|
TEST(ranges_test, format_adl_begin_end) {
|
||||||
|
auto b = adl::box{42};
|
||||||
|
EXPECT_EQ(fmt::format("{}", b), "[42]");
|
||||||
|
}
|
||||||
|
|
||||||
TEST(ranges_test, format_pair) {
|
TEST(ranges_test, format_pair) {
|
||||||
auto p = std::pair<int, float>(42, 1.5f);
|
auto p = std::pair<int, float>(42, 1.5f);
|
||||||
EXPECT_EQ(fmt::format("{}", p), "(42, 1.5)");
|
EXPECT_EQ(fmt::format("{}", p), "(42, 1.5)");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user