aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/fmt/test/ranges-test.cc
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:08 +0300
commit4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch)
tree506dac10f5df94fab310584ee51b24fc5a081c22 /contrib/libs/fmt/test/ranges-test.cc
parent2d37894b1b037cf24231090eda8589bbb44fb6fc (diff)
downloadydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/fmt/test/ranges-test.cc')
-rw-r--r--contrib/libs/fmt/test/ranges-test.cc136
1 files changed, 68 insertions, 68 deletions
diff --git a/contrib/libs/fmt/test/ranges-test.cc b/contrib/libs/fmt/test/ranges-test.cc
index 394f7b81be..fb3c9b45d1 100644
--- a/contrib/libs/fmt/test/ranges-test.cc
+++ b/contrib/libs/fmt/test/ranges-test.cc
@@ -54,7 +54,7 @@ TEST(RangesTest, FormatTuple) {
TEST(RangesTest, JoinTuple) {
// Value tuple args
std::tuple<char, int, float> t1 = std::make_tuple('a', 1, 2.0f);
- EXPECT_EQ("(a, 1, 2)", fmt::format("({})", fmt::join(t1, ", ")));
+ EXPECT_EQ("(a, 1, 2)", fmt::format("({})", fmt::join(t1, ", ")));
// Testing lvalue tuple args
int x = 4;
@@ -67,7 +67,7 @@ TEST(RangesTest, JoinTuple) {
// Single element tuple
std::tuple<float> t4{4.0f};
- EXPECT_EQ("4", fmt::format("{}", fmt::join(t4, "/")));
+ EXPECT_EQ("4", fmt::format("{}", fmt::join(t4, "/")));
}
TEST(RangesTest, JoinInitializerList) {
@@ -79,7 +79,7 @@ TEST(RangesTest, JoinInitializerList) {
struct my_struct {
int32_t i;
std::string str; // can throw
- template <size_t N> decltype(auto) get() const noexcept {
+ template <size_t N> decltype(auto) get() const noexcept {
if constexpr (N == 0)
return i;
else if constexpr (N == 1)
@@ -87,15 +87,15 @@ struct my_struct {
}
};
-template <size_t N> decltype(auto) get(const my_struct& s) noexcept {
+template <size_t N> decltype(auto) get(const my_struct& s) noexcept {
return s.get<N>();
}
namespace std {
-template <> struct tuple_size<my_struct> : std::integral_constant<size_t, 2> {};
+template <> struct tuple_size<my_struct> : std::integral_constant<size_t, 2> {};
-template <size_t N> struct tuple_element<N, my_struct> {
+template <size_t N> struct tuple_element<N, my_struct> {
using type = decltype(std::declval<my_struct>().get<N>());
};
@@ -139,65 +139,65 @@ TEST(RangesTest, FormatStringLike) {
EXPECT_EQ("foo", fmt::format("{}", string_like()));
}
#endif // FMT_USE_STRING_VIEW
-
-struct zstring_sentinel {};
-
-bool operator==(const char* p, zstring_sentinel) { return *p == '\0'; }
-bool operator!=(const char* p, zstring_sentinel) { return *p != '\0'; }
-
-struct zstring {
- const char* p;
- const char* begin() const { return p; }
- zstring_sentinel end() const { return {}; }
-};
-
-TEST(RangesTest, JoinSentinel) {
- zstring hello{"hello"};
- EXPECT_EQ("{'h', 'e', 'l', 'l', 'o'}", fmt::format("{}", hello));
- EXPECT_EQ("h_e_l_l_o", fmt::format("{}", fmt::join(hello, "_")));
-}
-
-// A range that provides non-const only begin()/end() to test fmt::join handles
-// that
-//
-// Some ranges (eg those produced by range-v3's views::filter()) can cache
-// information during iteration so they only provide non-const begin()/end().
-template <typename T> class non_const_only_range {
- private:
- std::vector<T> vec;
-
- public:
- using const_iterator = typename ::std::vector<T>::const_iterator;
-
- template <typename... Args>
- explicit non_const_only_range(Args&&... args)
- : vec(::std::forward<Args>(args)...) {}
-
- const_iterator begin() { return vec.begin(); }
- const_iterator end() { return vec.end(); }
-};
-
-TEST(RangesTest, JoinRange) {
- non_const_only_range<int> x(3u, 0);
- EXPECT_EQ("0,0,0", fmt::format("{}", fmt::join(x, ",")));
- EXPECT_EQ(
- "0,0,0",
- fmt::format("{}", fmt::join(non_const_only_range<int>(3u, 0), ",")));
-
- std::vector<int> y(3u, 0);
- EXPECT_EQ("0,0,0", fmt::format("{}", fmt::join(y, ",")));
- EXPECT_EQ("0,0,0",
- fmt::format("{}", fmt::join(std::vector<int>(3u, 0), ",")));
-
- const std::vector<int> z(3u, 0);
- EXPECT_EQ("0,0,0", fmt::format("{}", fmt::join(z, ",")));
-}
-
-#if !FMT_MSC_VER || FMT_MSC_VER >= 1927
-struct unformattable {};
-
-TEST(RangesTest, UnformattableRange) {
- EXPECT_FALSE((fmt::has_formatter<std::vector<unformattable>,
- fmt::format_context>::value));
-}
-#endif
+
+struct zstring_sentinel {};
+
+bool operator==(const char* p, zstring_sentinel) { return *p == '\0'; }
+bool operator!=(const char* p, zstring_sentinel) { return *p != '\0'; }
+
+struct zstring {
+ const char* p;
+ const char* begin() const { return p; }
+ zstring_sentinel end() const { return {}; }
+};
+
+TEST(RangesTest, JoinSentinel) {
+ zstring hello{"hello"};
+ EXPECT_EQ("{'h', 'e', 'l', 'l', 'o'}", fmt::format("{}", hello));
+ EXPECT_EQ("h_e_l_l_o", fmt::format("{}", fmt::join(hello, "_")));
+}
+
+// A range that provides non-const only begin()/end() to test fmt::join handles
+// that
+//
+// Some ranges (eg those produced by range-v3's views::filter()) can cache
+// information during iteration so they only provide non-const begin()/end().
+template <typename T> class non_const_only_range {
+ private:
+ std::vector<T> vec;
+
+ public:
+ using const_iterator = typename ::std::vector<T>::const_iterator;
+
+ template <typename... Args>
+ explicit non_const_only_range(Args&&... args)
+ : vec(::std::forward<Args>(args)...) {}
+
+ const_iterator begin() { return vec.begin(); }
+ const_iterator end() { return vec.end(); }
+};
+
+TEST(RangesTest, JoinRange) {
+ non_const_only_range<int> x(3u, 0);
+ EXPECT_EQ("0,0,0", fmt::format("{}", fmt::join(x, ",")));
+ EXPECT_EQ(
+ "0,0,0",
+ fmt::format("{}", fmt::join(non_const_only_range<int>(3u, 0), ",")));
+
+ std::vector<int> y(3u, 0);
+ EXPECT_EQ("0,0,0", fmt::format("{}", fmt::join(y, ",")));
+ EXPECT_EQ("0,0,0",
+ fmt::format("{}", fmt::join(std::vector<int>(3u, 0), ",")));
+
+ const std::vector<int> z(3u, 0);
+ EXPECT_EQ("0,0,0", fmt::format("{}", fmt::join(z, ",")));
+}
+
+#if !FMT_MSC_VER || FMT_MSC_VER >= 1927
+struct unformattable {};
+
+TEST(RangesTest, UnformattableRange) {
+ EXPECT_FALSE((fmt::has_formatter<std::vector<unformattable>,
+ fmt::format_context>::value));
+}
+#endif