aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/fmt/test
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:12 +0300
commit49116032d905455a7b1c994e4a696afc885c1e71 (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/fmt/test
parent4e839db24a3bbc9f1c610c43d6faaaa99824dcca (diff)
downloadydb-49116032d905455a7b1c994e4a696afc885c1e71.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/fmt/test')
-rw-r--r--contrib/libs/fmt/test/assert-test.cc10
-rw-r--r--contrib/libs/fmt/test/assert-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/chrono-test.cc26
-rw-r--r--contrib/libs/fmt/test/chrono-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/color-test.cc28
-rw-r--r--contrib/libs/fmt/test/color-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/compile-test.cc152
-rw-r--r--contrib/libs/fmt/test/compile-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/core-test.cc356
-rw-r--r--contrib/libs/fmt/test/core-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/format-impl-test.cc194
-rw-r--r--contrib/libs/fmt/test/format-impl-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/format-test.cc568
-rw-r--r--contrib/libs/fmt/test/format-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/gtest-extra-test.cc52
-rw-r--r--contrib/libs/fmt/test/gtest-extra-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/gtest-extra.cc6
-rw-r--r--contrib/libs/fmt/test/gtest-extra.h24
-rw-r--r--contrib/libs/fmt/test/header-only-test/ya.make16
-rw-r--r--contrib/libs/fmt/test/locale-test.cc174
-rw-r--r--contrib/libs/fmt/test/locale-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/mock-allocator.h8
-rw-r--r--contrib/libs/fmt/test/os-test.cc148
-rw-r--r--contrib/libs/fmt/test/os-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/ostream-test.cc130
-rw-r--r--contrib/libs/fmt/test/ostream-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/posix-mock-test.cc20
-rw-r--r--contrib/libs/fmt/test/posix-mock-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/printf-test.cc120
-rw-r--r--contrib/libs/fmt/test/printf-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/ranges-test.cc136
-rw-r--r--contrib/libs/fmt/test/ranges-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/scan-test.cc8
-rw-r--r--contrib/libs/fmt/test/scan-test/ya.make14
-rw-r--r--contrib/libs/fmt/test/scan.h34
-rw-r--r--contrib/libs/fmt/test/test-assert.h2
-rw-r--r--contrib/libs/fmt/test/util.cc2
-rw-r--r--contrib/libs/fmt/test/util.h2
-rw-r--r--contrib/libs/fmt/test/ya.make2
39 files changed, 1214 insertions, 1214 deletions
diff --git a/contrib/libs/fmt/test/assert-test.cc b/contrib/libs/fmt/test/assert-test.cc
index 4185afa3fa..73f622e56b 100644
--- a/contrib/libs/fmt/test/assert-test.cc
+++ b/contrib/libs/fmt/test/assert-test.cc
@@ -1,9 +1,9 @@
-// Formatting library for C++ - FMT_ASSERT test
+// Formatting library for C++ - FMT_ASSERT test
+//
+// It is a separate test to minimize the number of EXPECT_DEBUG_DEATH checks
+// which are slow on some platforms. In other tests FMT_ASSERT is made to throw
+// an exception which is much faster and easier to check.
//
-// It is a separate test to minimize the number of EXPECT_DEBUG_DEATH checks
-// which are slow on some platforms. In other tests FMT_ASSERT is made to throw
-// an exception which is much faster and easier to check.
-//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
diff --git a/contrib/libs/fmt/test/assert-test/ya.make b/contrib/libs/fmt/test/assert-test/ya.make
index db43656cce..22d19ae00a 100644
--- a/contrib/libs/fmt/test/assert-test/ya.make
+++ b/contrib/libs/fmt/test/assert-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/chrono-test.cc b/contrib/libs/fmt/test/chrono-test.cc
index 774dfb5d25..fa383c1446 100644
--- a/contrib/libs/fmt/test/chrono-test.cc
+++ b/contrib/libs/fmt/test/chrono-test.cc
@@ -13,8 +13,8 @@
#include <iomanip>
-#include "gtest-extra.h"
-
+#include "gtest-extra.h"
+
std::tm make_tm() {
auto time = std::tm();
time.tm_mday = 1;
@@ -95,17 +95,17 @@ TEST(TimeTest, GMTime) {
EXPECT_TRUE(EqualTime(tm, fmt::gmtime(t)));
}
-TEST(TimeTest, TimePoint) {
- std::chrono::system_clock::time_point point = std::chrono::system_clock::now();
-
- std::time_t t = std::chrono::system_clock::to_time_t(point);
- std::tm tm = *std::localtime(&t);
- char strftime_output[256];
- std::strftime(strftime_output, sizeof(strftime_output), "It is %Y-%m-%d %H:%M:%S", &tm);
-
- EXPECT_EQ(strftime_output, fmt::format("It is {:%Y-%m-%d %H:%M:%S}", point));
-}
-
+TEST(TimeTest, TimePoint) {
+ std::chrono::system_clock::time_point point = std::chrono::system_clock::now();
+
+ std::time_t t = std::chrono::system_clock::to_time_t(point);
+ std::tm tm = *std::localtime(&t);
+ char strftime_output[256];
+ std::strftime(strftime_output, sizeof(strftime_output), "It is %Y-%m-%d %H:%M:%S", &tm);
+
+ EXPECT_EQ(strftime_output, fmt::format("It is {:%Y-%m-%d %H:%M:%S}", point));
+}
+
#define EXPECT_TIME(spec, time, duration) \
{ \
std::locale loc("ja_JP.utf8"); \
diff --git a/contrib/libs/fmt/test/chrono-test/ya.make b/contrib/libs/fmt/test/chrono-test/ya.make
index 8eed734b6a..7982d65069 100644
--- a/contrib/libs/fmt/test/chrono-test/ya.make
+++ b/contrib/libs/fmt/test/chrono-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/color-test.cc b/contrib/libs/fmt/test/color-test.cc
index 25bea49784..3073808541 100644
--- a/contrib/libs/fmt/test/color-test.cc
+++ b/contrib/libs/fmt/test/color-test.cc
@@ -6,11 +6,11 @@
// For the license information refer to format.h.
#include "fmt/color.h"
-
-#include <iterator>
-#include <string>
-#include <utility>
-
+
+#include <iterator>
+#include <string>
+#include <utility>
+
#include "gtest-extra.h"
TEST(ColorsTest, ColorsPrint) {
@@ -88,12 +88,12 @@ TEST(ColorsTest, Format) {
EXPECT_EQ(fmt::format(fg(fmt::terminal_color::red), "{}", "foo"),
"\x1b[31mfoo\x1b[0m");
}
-
-TEST(ColorsTest, FormatToOutAcceptsTextStyle) {
- fmt::text_style ts = fg(fmt::rgb(255, 20, 30));
- std::string out;
- fmt::format_to(std::back_inserter(out), ts, "rgb(255,20,30){}{}{}", 1, 2, 3);
-
- EXPECT_EQ(fmt::to_string(out),
- "\x1b[38;2;255;020;030mrgb(255,20,30)123\x1b[0m");
-}
+
+TEST(ColorsTest, FormatToOutAcceptsTextStyle) {
+ fmt::text_style ts = fg(fmt::rgb(255, 20, 30));
+ std::string out;
+ fmt::format_to(std::back_inserter(out), ts, "rgb(255,20,30){}{}{}", 1, 2, 3);
+
+ EXPECT_EQ(fmt::to_string(out),
+ "\x1b[38;2;255;020;030mrgb(255,20,30)123\x1b[0m");
+}
diff --git a/contrib/libs/fmt/test/color-test/ya.make b/contrib/libs/fmt/test/color-test/ya.make
index 3f01731237..22e6654b0f 100644
--- a/contrib/libs/fmt/test/color-test/ya.make
+++ b/contrib/libs/fmt/test/color-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/compile-test.cc b/contrib/libs/fmt/test/compile-test.cc
index 282405328a..9bb9bb7d9e 100644
--- a/contrib/libs/fmt/test/compile-test.cc
+++ b/contrib/libs/fmt/test/compile-test.cc
@@ -6,9 +6,9 @@
// For the license information refer to format.h.
#include <string>
-#include <type_traits>
+#include <type_traits>
-// Check that fmt/compile.h compiles with windows.h included before it.
+// Check that fmt/compile.h compiles with windows.h included before it.
#ifdef _WIN32
# include <windows.h>
#endif
@@ -23,8 +23,8 @@
#if FMT_USE_CONSTEXPR
template <unsigned EXPECTED_PARTS_COUNT, typename Format>
void check_prepared_parts_type(Format format) {
- typedef fmt::detail::compiled_format_base<decltype(format)> provider;
- typedef fmt::detail::format_part<char>
+ typedef fmt::detail::compiled_format_base<decltype(format)> provider;
+ typedef fmt::detail::format_part<char>
expected_parts_type[EXPECTED_PARTS_COUNT];
static_assert(std::is_same<typename provider::parts_container,
expected_parts_type>::value,
@@ -50,37 +50,37 @@ TEST(CompileTest, CompileTimePreparedPartsTypeProvider) {
#endif
TEST(CompileTest, PassStringLiteralFormat) {
- const auto prepared = fmt::detail::compile<int>("test {}");
+ const auto prepared = fmt::detail::compile<int>("test {}");
EXPECT_EQ("test 42", fmt::format(prepared, 42));
- const auto wprepared = fmt::detail::compile<int>(L"test {}");
+ const auto wprepared = fmt::detail::compile<int>(L"test {}");
EXPECT_EQ(L"test 42", fmt::format(wprepared, 42));
}
TEST(CompileTest, FormatToArrayOfChars) {
char buffer[32] = {0};
- const auto prepared = fmt::detail::compile<int>("4{}");
- fmt::format_to(fmt::detail::make_checked(buffer, 32), prepared, 2);
+ const auto prepared = fmt::detail::compile<int>("4{}");
+ fmt::format_to(fmt::detail::make_checked(buffer, 32), prepared, 2);
EXPECT_EQ(std::string("42"), buffer);
wchar_t wbuffer[32] = {0};
- const auto wprepared = fmt::detail::compile<int>(L"4{}");
- fmt::format_to(fmt::detail::make_checked(wbuffer, 32), wprepared, 2);
+ const auto wprepared = fmt::detail::compile<int>(L"4{}");
+ fmt::format_to(fmt::detail::make_checked(wbuffer, 32), wprepared, 2);
EXPECT_EQ(std::wstring(L"42"), wbuffer);
}
TEST(CompileTest, FormatToIterator) {
std::string s(2, ' ');
- const auto prepared = fmt::detail::compile<int>("4{}");
+ const auto prepared = fmt::detail::compile<int>("4{}");
fmt::format_to(s.begin(), prepared, 2);
EXPECT_EQ("42", s);
std::wstring ws(2, L' ');
- const auto wprepared = fmt::detail::compile<int>(L"4{}");
+ const auto wprepared = fmt::detail::compile<int>(L"4{}");
fmt::format_to(ws.begin(), wprepared, 2);
EXPECT_EQ(L"42", ws);
}
TEST(CompileTest, FormatToN) {
char buf[5];
- auto f = fmt::detail::compile<int>("{:10}");
+ auto f = fmt::detail::compile<int>("{:10}");
auto result = fmt::format_to_n(buf, 5, f, 42);
EXPECT_EQ(result.size, 10);
EXPECT_EQ(result.out, buf + 5);
@@ -88,86 +88,86 @@ TEST(CompileTest, FormatToN) {
}
TEST(CompileTest, FormattedSize) {
- auto f = fmt::detail::compile<int>("{:10}");
+ auto f = fmt::detail::compile<int>("{:10}");
EXPECT_EQ(fmt::formatted_size(f, 42), 10);
}
TEST(CompileTest, MultipleTypes) {
- auto f = fmt::detail::compile<int, int>("{} {}");
+ auto f = fmt::detail::compile<int, int>("{} {}");
EXPECT_EQ(fmt::format(f, 42, 42), "42 42");
}
-struct test_formattable {};
+struct test_formattable {};
FMT_BEGIN_NAMESPACE
-template <> struct formatter<test_formattable> : formatter<const char*> {
- template <typename FormatContext>
- auto format(test_formattable, FormatContext& ctx) -> decltype(ctx.out()) {
+template <> struct formatter<test_formattable> : formatter<const char*> {
+ template <typename FormatContext>
+ auto format(test_formattable, FormatContext& ctx) -> decltype(ctx.out()) {
return formatter<const char*>::format("foo", ctx);
}
};
FMT_END_NAMESPACE
TEST(CompileTest, FormatUserDefinedType) {
- auto f = fmt::detail::compile<test_formattable>("{}");
- EXPECT_EQ(fmt::format(f, test_formattable()), "foo");
+ auto f = fmt::detail::compile<test_formattable>("{}");
+ EXPECT_EQ(fmt::format(f, test_formattable()), "foo");
}
TEST(CompileTest, EmptyFormatString) {
- auto f = fmt::detail::compile<>("");
+ auto f = fmt::detail::compile<>("");
EXPECT_EQ(fmt::format(f), "");
}
-
-#ifdef __cpp_if_constexpr
-TEST(CompileTest, FormatDefault) {
- EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42));
- EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42u));
- EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42ll));
- EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42ull));
- EXPECT_EQ("true", fmt::format(FMT_COMPILE("{}"), true));
- EXPECT_EQ("x", fmt::format(FMT_COMPILE("{}"), 'x'));
- EXPECT_EQ("4.2", fmt::format(FMT_COMPILE("{}"), 4.2));
- EXPECT_EQ("foo", fmt::format(FMT_COMPILE("{}"), "foo"));
- EXPECT_EQ("foo", fmt::format(FMT_COMPILE("{}"), std::string("foo")));
- EXPECT_EQ("foo", fmt::format(FMT_COMPILE("{}"), test_formattable()));
-}
-
-TEST(CompileTest, FormatWideString) {
- EXPECT_EQ(L"42", fmt::format(FMT_COMPILE(L"{}"), 42));
-}
-
-TEST(CompileTest, FormatSpecs) {
- EXPECT_EQ("42", fmt::format(FMT_COMPILE("{:x}"), 0x42));
-}
-
-TEST(CompileTest, DynamicWidth) {
- EXPECT_EQ(" 42foo ",
- fmt::format(FMT_COMPILE("{:{}}{:{}}"), 42, 4, "foo", 5));
-}
-
-TEST(CompileTest, FormatTo) {
- char buf[8];
- auto end = fmt::format_to(buf, FMT_COMPILE("{}"), 42);
- *end = '\0';
- EXPECT_STREQ("42", buf);
- end = fmt::format_to(buf, FMT_COMPILE("{:x}"), 42);
- *end = '\0';
- EXPECT_STREQ("2a", buf);
-}
-
-TEST(CompileTest, FormatToNWithCompileMacro) {
- constexpr auto buffer_size = 8;
- char buffer[buffer_size];
- auto res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{}"), 42);
- *res.out = '\0';
- EXPECT_STREQ("42", buffer);
- res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{:x}"), 42);
- *res.out = '\0';
- EXPECT_STREQ("2a", buffer);
-}
-
-TEST(CompileTest, TextAndArg) {
- EXPECT_EQ(">>>42<<<", fmt::format(FMT_COMPILE(">>>{}<<<"), 42));
- EXPECT_EQ("42!", fmt::format(FMT_COMPILE("{}!"), 42));
-}
-#endif
+
+#ifdef __cpp_if_constexpr
+TEST(CompileTest, FormatDefault) {
+ EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42));
+ EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42u));
+ EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42ll));
+ EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), 42ull));
+ EXPECT_EQ("true", fmt::format(FMT_COMPILE("{}"), true));
+ EXPECT_EQ("x", fmt::format(FMT_COMPILE("{}"), 'x'));
+ EXPECT_EQ("4.2", fmt::format(FMT_COMPILE("{}"), 4.2));
+ EXPECT_EQ("foo", fmt::format(FMT_COMPILE("{}"), "foo"));
+ EXPECT_EQ("foo", fmt::format(FMT_COMPILE("{}"), std::string("foo")));
+ EXPECT_EQ("foo", fmt::format(FMT_COMPILE("{}"), test_formattable()));
+}
+
+TEST(CompileTest, FormatWideString) {
+ EXPECT_EQ(L"42", fmt::format(FMT_COMPILE(L"{}"), 42));
+}
+
+TEST(CompileTest, FormatSpecs) {
+ EXPECT_EQ("42", fmt::format(FMT_COMPILE("{:x}"), 0x42));
+}
+
+TEST(CompileTest, DynamicWidth) {
+ EXPECT_EQ(" 42foo ",
+ fmt::format(FMT_COMPILE("{:{}}{:{}}"), 42, 4, "foo", 5));
+}
+
+TEST(CompileTest, FormatTo) {
+ char buf[8];
+ auto end = fmt::format_to(buf, FMT_COMPILE("{}"), 42);
+ *end = '\0';
+ EXPECT_STREQ("42", buf);
+ end = fmt::format_to(buf, FMT_COMPILE("{:x}"), 42);
+ *end = '\0';
+ EXPECT_STREQ("2a", buf);
+}
+
+TEST(CompileTest, FormatToNWithCompileMacro) {
+ constexpr auto buffer_size = 8;
+ char buffer[buffer_size];
+ auto res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{}"), 42);
+ *res.out = '\0';
+ EXPECT_STREQ("42", buffer);
+ res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{:x}"), 42);
+ *res.out = '\0';
+ EXPECT_STREQ("2a", buffer);
+}
+
+TEST(CompileTest, TextAndArg) {
+ EXPECT_EQ(">>>42<<<", fmt::format(FMT_COMPILE(">>>{}<<<"), 42));
+ EXPECT_EQ("42!", fmt::format(FMT_COMPILE("{}!"), 42));
+}
+#endif
diff --git a/contrib/libs/fmt/test/compile-test/ya.make b/contrib/libs/fmt/test/compile-test/ya.make
index 32ff1b710a..0173e7e70f 100644
--- a/contrib/libs/fmt/test/compile-test/ya.make
+++ b/contrib/libs/fmt/test/compile-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/core-test.cc b/contrib/libs/fmt/test/core-test.cc
index 119323c3d3..a5fd01fa4d 100644
--- a/contrib/libs/fmt/test/core-test.cc
+++ b/contrib/libs/fmt/test/core-test.cc
@@ -30,13 +30,13 @@
using fmt::basic_format_arg;
using fmt::string_view;
-using fmt::detail::buffer;
-using fmt::detail::make_arg;
-using fmt::detail::value;
+using fmt::detail::buffer;
+using fmt::detail::make_arg;
+using fmt::detail::value;
using testing::_;
-using testing::Invoke;
-using testing::Return;
+using testing::Invoke;
+using testing::Return;
using testing::StrictMock;
struct test_struct {};
@@ -48,7 +48,7 @@ template <typename Char> struct formatter<test_struct, Char> {
return ctx.begin();
}
- auto format(test_struct, format_context& ctx) -> decltype(ctx.out()) {
+ auto format(test_struct, format_context& ctx) -> decltype(ctx.out()) {
const Char* test = "test";
return std::copy_n(test, std::strlen(test), ctx.out());
}
@@ -73,21 +73,21 @@ TEST(BufferTest, Nonmoveable) {
}
#endif
-TEST(BufferTest, Indestructible) {
- static_assert(!std::is_destructible<fmt::detail::buffer<int>>(),
- "buffer's destructor is protected");
-}
-
-template <typename T> struct mock_buffer final : buffer<T> {
- MOCK_METHOD1(do_grow, size_t(size_t capacity));
-
- void grow(size_t capacity) { this->set(this->data(), do_grow(capacity)); }
-
- mock_buffer(T* data = nullptr, size_t capacity = 0) {
- this->set(data, capacity);
- ON_CALL(*this, do_grow(_)).WillByDefault(Invoke([](size_t capacity) {
- return capacity;
- }));
+TEST(BufferTest, Indestructible) {
+ static_assert(!std::is_destructible<fmt::detail::buffer<int>>(),
+ "buffer's destructor is protected");
+}
+
+template <typename T> struct mock_buffer final : buffer<T> {
+ MOCK_METHOD1(do_grow, size_t(size_t capacity));
+
+ void grow(size_t capacity) { this->set(this->data(), do_grow(capacity)); }
+
+ mock_buffer(T* data = nullptr, size_t capacity = 0) {
+ this->set(data, capacity);
+ ON_CALL(*this, do_grow(_)).WillByDefault(Invoke([](size_t capacity) {
+ return capacity;
+ }));
}
};
@@ -107,7 +107,7 @@ TEST(BufferTest, Ctor) {
}
{
int dummy;
- size_t capacity = std::numeric_limits<size_t>::max();
+ size_t capacity = std::numeric_limits<size_t>::max();
mock_buffer<int> buffer(&dummy, capacity);
EXPECT_EQ(&dummy, &buffer[0]);
EXPECT_EQ(static_cast<size_t>(0), buffer.size());
@@ -122,44 +122,44 @@ TEST(BufferTest, Access) {
EXPECT_EQ(11, buffer[0]);
buffer[3] = 42;
EXPECT_EQ(42, *(&buffer[0] + 3));
- const fmt::detail::buffer<char>& const_buffer = buffer;
+ const fmt::detail::buffer<char>& const_buffer = buffer;
EXPECT_EQ(42, const_buffer[3]);
}
-TEST(BufferTest, TryResize) {
+TEST(BufferTest, TryResize) {
char data[123];
mock_buffer<char> buffer(data, sizeof(data));
buffer[10] = 42;
EXPECT_EQ(42, buffer[10]);
- buffer.try_resize(20);
+ buffer.try_resize(20);
EXPECT_EQ(20u, buffer.size());
EXPECT_EQ(123u, buffer.capacity());
EXPECT_EQ(42, buffer[10]);
- buffer.try_resize(5);
+ buffer.try_resize(5);
EXPECT_EQ(5u, buffer.size());
EXPECT_EQ(123u, buffer.capacity());
EXPECT_EQ(42, buffer[10]);
- // Check if try_resize calls grow.
+ // Check if try_resize calls grow.
EXPECT_CALL(buffer, do_grow(124));
- buffer.try_resize(124);
+ buffer.try_resize(124);
EXPECT_CALL(buffer, do_grow(200));
- buffer.try_resize(200);
-}
-
-TEST(BufferTest, TryResizePartial) {
- char data[10];
- mock_buffer<char> buffer(data, sizeof(data));
- EXPECT_CALL(buffer, do_grow(20)).WillOnce(Return(15));
- buffer.try_resize(20);
- EXPECT_EQ(buffer.capacity(), 15);
- EXPECT_EQ(buffer.size(), 15);
-}
-
+ buffer.try_resize(200);
+}
+
+TEST(BufferTest, TryResizePartial) {
+ char data[10];
+ mock_buffer<char> buffer(data, sizeof(data));
+ EXPECT_CALL(buffer, do_grow(20)).WillOnce(Return(15));
+ buffer.try_resize(20);
+ EXPECT_EQ(buffer.capacity(), 15);
+ EXPECT_EQ(buffer.size(), 15);
+}
+
TEST(BufferTest, Clear) {
- mock_buffer<char> buffer;
- EXPECT_CALL(buffer, do_grow(20));
- buffer.try_resize(20);
- buffer.try_resize(0);
+ mock_buffer<char> buffer;
+ EXPECT_CALL(buffer, do_grow(20));
+ buffer.try_resize(20);
+ buffer.try_resize(0);
EXPECT_EQ(static_cast<size_t>(0), buffer.size());
EXPECT_EQ(20u, buffer.capacity());
}
@@ -167,11 +167,11 @@ TEST(BufferTest, Clear) {
TEST(BufferTest, Append) {
char data[15];
mock_buffer<char> buffer(data, 10);
- auto test = "test";
+ auto test = "test";
buffer.append(test, test + 5);
EXPECT_STREQ(test, &buffer[0]);
EXPECT_EQ(5u, buffer.size());
- buffer.try_resize(10);
+ buffer.try_resize(10);
EXPECT_CALL(buffer, do_grow(12));
buffer.append(test, test + 2);
EXPECT_EQ('t', buffer[10]);
@@ -179,31 +179,31 @@ TEST(BufferTest, Append) {
EXPECT_EQ(12u, buffer.size());
}
-TEST(BufferTest, AppendPartial) {
- char data[10];
- mock_buffer<char> buffer(data, sizeof(data));
- testing::InSequence seq;
- EXPECT_CALL(buffer, do_grow(15)).WillOnce(Return(10));
- EXPECT_CALL(buffer, do_grow(15)).WillOnce(Invoke([&buffer](size_t) {
- EXPECT_EQ(fmt::string_view(buffer.data(), buffer.size()), "0123456789");
- buffer.clear();
- return 10;
- }));
- auto test = "0123456789abcde";
- buffer.append(test, test + 15);
-}
-
+TEST(BufferTest, AppendPartial) {
+ char data[10];
+ mock_buffer<char> buffer(data, sizeof(data));
+ testing::InSequence seq;
+ EXPECT_CALL(buffer, do_grow(15)).WillOnce(Return(10));
+ EXPECT_CALL(buffer, do_grow(15)).WillOnce(Invoke([&buffer](size_t) {
+ EXPECT_EQ(fmt::string_view(buffer.data(), buffer.size()), "0123456789");
+ buffer.clear();
+ return 10;
+ }));
+ auto test = "0123456789abcde";
+ buffer.append(test, test + 15);
+}
+
TEST(BufferTest, AppendAllocatesEnoughStorage) {
char data[19];
mock_buffer<char> buffer(data, 10);
- auto test = "abcdefgh";
- buffer.try_resize(10);
+ auto test = "abcdefgh";
+ buffer.try_resize(10);
EXPECT_CALL(buffer, do_grow(19));
buffer.append(test, test + 9);
}
TEST(ArgTest, FormatArgs) {
- auto args = fmt::format_args();
+ auto args = fmt::format_args();
EXPECT_FALSE(args.get(1));
}
@@ -231,21 +231,21 @@ struct custom_context {
};
TEST(ArgTest, MakeValueWithCustomContext) {
- auto t = test_struct();
- fmt::detail::value<custom_context> arg(
- fmt::detail::arg_mapper<custom_context>().map(t));
+ auto t = test_struct();
+ fmt::detail::value<custom_context> arg(
+ fmt::detail::arg_mapper<custom_context>().map(t));
custom_context ctx = {false, fmt::format_parse_context("")};
arg.custom.format(&t, ctx.parse_context(), ctx);
EXPECT_TRUE(ctx.called);
}
FMT_BEGIN_NAMESPACE
-namespace detail {
+namespace detail {
template <typename Char>
bool operator==(custom_value<Char> lhs, custom_value<Char> rhs) {
return lhs.value == rhs.value;
}
-} // namespace detail
+} // namespace detail
FMT_END_NAMESPACE
// Use a unique result type to make sure that there are no undesirable
@@ -253,10 +253,10 @@ FMT_END_NAMESPACE
struct test_result {};
template <typename T> struct mock_visitor {
- template <typename U> struct result { using type = test_result; };
+ template <typename U> struct result { using type = test_result; };
mock_visitor() {
- ON_CALL(*this, visit(_)).WillByDefault(Return(test_result()));
+ ON_CALL(*this, visit(_)).WillByDefault(Return(test_result()));
}
MOCK_METHOD1_T(visit, test_result(T value));
@@ -270,10 +270,10 @@ template <typename T> struct mock_visitor {
}
};
-template <typename T> struct visit_type { using type = T; };
+template <typename T> struct visit_type { using type = T; };
-#define VISIT_TYPE(type_, visit_type_) \
- template <> struct visit_type<type_> { using type = visit_type_; }
+#define VISIT_TYPE(type_, visit_type_) \
+ template <> struct visit_type<type_> { using type = visit_type_; }
VISIT_TYPE(signed char, int);
VISIT_TYPE(unsigned char, unsigned);
@@ -292,34 +292,34 @@ VISIT_TYPE(unsigned long, unsigned long long);
{ \
testing::StrictMock<mock_visitor<decltype(expected)>> visitor; \
EXPECT_CALL(visitor, visit(expected)); \
- using iterator = std::back_insert_iterator<buffer<Char>>; \
+ using iterator = std::back_insert_iterator<buffer<Char>>; \
fmt::visit_format_arg( \
visitor, make_arg<fmt::basic_format_context<iterator, Char>>(value)); \
}
#define CHECK_ARG(value, typename_) \
{ \
- using value_type = decltype(value); \
- typename_ visit_type<value_type>::type expected = value; \
+ using value_type = decltype(value); \
+ typename_ visit_type<value_type>::type expected = value; \
CHECK_ARG_(char, expected, value) \
CHECK_ARG_(wchar_t, expected, value) \
}
template <typename T> class NumericArgTest : public testing::Test {};
-using types =
- ::testing::Types<bool, signed char, unsigned char, signed, unsigned short,
- int, unsigned, long, unsigned long, long long,
- unsigned long long, float, double, long double>;
-TYPED_TEST_CASE(NumericArgTest, types);
+using types =
+ ::testing::Types<bool, signed char, unsigned char, signed, unsigned short,
+ int, unsigned, long, unsigned long, long long,
+ unsigned long long, float, double, long double>;
+TYPED_TEST_CASE(NumericArgTest, types);
template <typename T>
-fmt::enable_if_t<std::is_integral<T>::value, T> test_value() {
+fmt::enable_if_t<std::is_integral<T>::value, T> test_value() {
return static_cast<T>(42);
}
template <typename T>
-fmt::enable_if_t<std::is_floating_point<T>::value, T> test_value() {
+fmt::enable_if_t<std::is_floating_point<T>::value, T> test_value() {
return static_cast<T>(4.2);
}
@@ -341,7 +341,7 @@ TEST(ArgTest, StringArg) {
const char* cstr = str;
CHECK_ARG_(char, cstr, str);
- auto sref = string_view(str);
+ auto sref = string_view(str);
CHECK_ARG_(char, sref, std::string(str));
}
@@ -368,14 +368,14 @@ TEST(ArgTest, PointerArg) {
struct check_custom {
test_result operator()(
fmt::basic_format_arg<fmt::format_context>::handle h) const {
- struct test_buffer final : fmt::detail::buffer<char> {
+ struct test_buffer final : fmt::detail::buffer<char> {
char data[10];
- test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {}
- void grow(size_t) {}
+ test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {}
+ void grow(size_t) {}
} buffer;
fmt::format_parse_context parse_ctx("");
- fmt::format_context ctx{fmt::detail::buffer_appender<char>(buffer),
- fmt::format_args()};
+ fmt::format_context ctx{fmt::detail::buffer_appender<char>(buffer),
+ fmt::format_args()};
h.format(parse_ctx, ctx);
EXPECT_EQ("test", std::string(buffer.data, buffer.size()));
return test_result();
@@ -384,10 +384,10 @@ struct check_custom {
TEST(ArgTest, CustomArg) {
test_struct test;
- using visitor =
- mock_visitor<fmt::basic_format_arg<fmt::format_context>::handle>;
+ using visitor =
+ mock_visitor<fmt::basic_format_arg<fmt::format_context>::handle>;
testing::StrictMock<visitor> v;
- EXPECT_CALL(v, visit(_)).WillOnce(Invoke(check_custom()));
+ EXPECT_CALL(v, visit(_)).WillOnce(Invoke(check_custom()));
fmt::visit_format_arg(v, make_arg<fmt::format_context>(test));
}
@@ -403,7 +403,7 @@ TEST(FormatDynArgsTest, Basic) {
store.push_back(42);
store.push_back("abc1");
store.push_back(1.5f);
- EXPECT_EQ("42 and abc1 and 1.5", fmt::vformat("{} and {} and {}", store));
+ EXPECT_EQ("42 and abc1 and 1.5", fmt::vformat("{} and {} and {}", store));
}
TEST(FormatDynArgsTest, StringsAndRefs) {
@@ -449,21 +449,21 @@ TEST(FormatDynArgsTest, CustomFormat) {
EXPECT_EQ("cust=0 and cust=1 and cust=3", result);
}
-TEST(FormatDynArgsTest, NamedInt) {
- fmt::dynamic_format_arg_store<fmt::format_context> store;
- store.push_back(fmt::arg("a1", 42));
- EXPECT_EQ("42", fmt::vformat("{a1}", store));
-}
-
-TEST(FormatDynArgsTest, NamedStrings) {
- fmt::dynamic_format_arg_store<fmt::format_context> store;
- char str[]{"1234567890"};
- store.push_back(fmt::arg("a1", str));
- store.push_back(fmt::arg("a2", std::cref(str)));
- str[0] = 'X';
- EXPECT_EQ("1234567890 and X234567890", fmt::vformat("{a1} and {a2}", store));
-}
-
+TEST(FormatDynArgsTest, NamedInt) {
+ fmt::dynamic_format_arg_store<fmt::format_context> store;
+ store.push_back(fmt::arg("a1", 42));
+ EXPECT_EQ("42", fmt::vformat("{a1}", store));
+}
+
+TEST(FormatDynArgsTest, NamedStrings) {
+ fmt::dynamic_format_arg_store<fmt::format_context> store;
+ char str[]{"1234567890"};
+ store.push_back(fmt::arg("a1", str));
+ store.push_back(fmt::arg("a2", std::cref(str)));
+ str[0] = 'X';
+ EXPECT_EQ("1234567890 and X234567890", fmt::vformat("{a1} and {a2}", store));
+}
+
TEST(FormatDynArgsTest, NamedArgByRef) {
fmt::dynamic_format_arg_store<fmt::format_context> store;
@@ -478,53 +478,53 @@ TEST(FormatDynArgsTest, NamedArgByRef) {
// storages.
int a1_val{42};
auto a1 = fmt::arg("a1_", a1_val);
- store.push_back("abc");
- store.push_back(1.5f);
+ store.push_back("abc");
+ store.push_back(1.5f);
store.push_back(std::cref(a1));
- std::string result = fmt::vformat("{a1_} and {} and {} and {}", store);
- EXPECT_EQ("42 and abc and 1.5 and 42", result);
-}
-
-TEST(FormatDynArgsTest, NamedCustomFormat) {
- fmt::dynamic_format_arg_store<fmt::format_context> store;
- custom_type c{};
- store.push_back(fmt::arg("c1", c));
- ++c.i;
- store.push_back(fmt::arg("c2", c));
- ++c.i;
- store.push_back(fmt::arg("c_ref", std::cref(c)));
- ++c.i;
- std::string result = fmt::vformat("{c1} and {c2} and {c_ref}", store);
- EXPECT_EQ("cust=0 and cust=1 and cust=3", result);
-}
-
-TEST(FormatDynArgsTest, Clear) {
- fmt::dynamic_format_arg_store<fmt::format_context> store;
- store.push_back(42);
-
- std::string result = fmt::vformat("{}", store);
+ std::string result = fmt::vformat("{a1_} and {} and {} and {}", store);
+ EXPECT_EQ("42 and abc and 1.5 and 42", result);
+}
+
+TEST(FormatDynArgsTest, NamedCustomFormat) {
+ fmt::dynamic_format_arg_store<fmt::format_context> store;
+ custom_type c{};
+ store.push_back(fmt::arg("c1", c));
+ ++c.i;
+ store.push_back(fmt::arg("c2", c));
+ ++c.i;
+ store.push_back(fmt::arg("c_ref", std::cref(c)));
+ ++c.i;
+ std::string result = fmt::vformat("{c1} and {c2} and {c_ref}", store);
+ EXPECT_EQ("cust=0 and cust=1 and cust=3", result);
+}
+
+TEST(FormatDynArgsTest, Clear) {
+ fmt::dynamic_format_arg_store<fmt::format_context> store;
+ store.push_back(42);
+
+ std::string result = fmt::vformat("{}", store);
EXPECT_EQ("42", result);
-
- store.push_back(43);
- result = fmt::vformat("{} and {}", store);
- EXPECT_EQ("42 and 43", result);
-
- store.clear();
- store.push_back(44);
- result = fmt::vformat("{}", store);
- EXPECT_EQ("44", result);
-}
-
-TEST(FormatDynArgsTest, Reserve) {
- fmt::dynamic_format_arg_store<fmt::format_context> store;
- store.reserve(2, 1);
- store.push_back(1.5f);
- store.push_back(fmt::arg("a1", 42));
- std::string result = fmt::vformat("{a1} and {}", store);
- EXPECT_EQ("42 and 1.5", result);
-}
-
+
+ store.push_back(43);
+ result = fmt::vformat("{} and {}", store);
+ EXPECT_EQ("42 and 43", result);
+
+ store.clear();
+ store.push_back(44);
+ result = fmt::vformat("{}", store);
+ EXPECT_EQ("44", result);
+}
+
+TEST(FormatDynArgsTest, Reserve) {
+ fmt::dynamic_format_arg_store<fmt::format_context> store;
+ store.reserve(2, 1);
+ store.push_back(1.5f);
+ store.push_back(fmt::arg("a1", 42));
+ std::string result = fmt::vformat("{a1} and {}", store);
+ EXPECT_EQ("42 and 1.5", result);
+}
+
struct copy_throwable {
copy_throwable() {}
copy_throwable(const copy_throwable&) { throw "deal with it"; }
@@ -565,9 +565,9 @@ TEST(StringViewTest, Length) {
// Check string_view's comparison operator.
template <template <typename> class Op> void check_op() {
const char* inputs[] = {"foo", "fop", "fo"};
- size_t num_inputs = sizeof(inputs) / sizeof(*inputs);
- for (size_t i = 0; i < num_inputs; ++i) {
- for (size_t j = 0; j < num_inputs; ++j) {
+ size_t num_inputs = sizeof(inputs) / sizeof(*inputs);
+ for (size_t i = 0; i < num_inputs; ++i) {
+ for (size_t j = 0; j < num_inputs; ++j) {
string_view lhs(inputs[i]), rhs(inputs[j]);
EXPECT_EQ(Op<int>()(lhs.compare(rhs), 0), Op<string_view>()(lhs, rhs));
}
@@ -650,13 +650,13 @@ TEST(CoreTest, FormatterOverridesImplicitConversion) {
namespace my_ns {
template <typename Char> class my_string {
- private:
- std::basic_string<Char> s_;
-
+ private:
+ std::basic_string<Char> s_;
+
public:
my_string(const Char* s) : s_(s) {}
const Char* data() const FMT_NOEXCEPT { return s_.data(); }
- size_t length() const FMT_NOEXCEPT { return s_.size(); }
+ size_t length() const FMT_NOEXCEPT { return s_.size(); }
operator const Char*() const { return s_.c_str(); }
};
@@ -680,19 +680,19 @@ struct derived_from_string_view : fmt::basic_string_view<Char> {};
} // namespace
TYPED_TEST(IsStringTest, IsString) {
- EXPECT_TRUE(fmt::detail::is_string<TypeParam*>::value);
- EXPECT_TRUE(fmt::detail::is_string<const TypeParam*>::value);
- EXPECT_TRUE(fmt::detail::is_string<TypeParam[2]>::value);
- EXPECT_TRUE(fmt::detail::is_string<const TypeParam[2]>::value);
- EXPECT_TRUE(fmt::detail::is_string<std::basic_string<TypeParam>>::value);
- EXPECT_TRUE(fmt::detail::is_string<fmt::basic_string_view<TypeParam>>::value);
+ EXPECT_TRUE(fmt::detail::is_string<TypeParam*>::value);
+ EXPECT_TRUE(fmt::detail::is_string<const TypeParam*>::value);
+ EXPECT_TRUE(fmt::detail::is_string<TypeParam[2]>::value);
+ EXPECT_TRUE(fmt::detail::is_string<const TypeParam[2]>::value);
+ EXPECT_TRUE(fmt::detail::is_string<std::basic_string<TypeParam>>::value);
+ EXPECT_TRUE(fmt::detail::is_string<fmt::basic_string_view<TypeParam>>::value);
EXPECT_TRUE(
- fmt::detail::is_string<derived_from_string_view<TypeParam>>::value);
- using string_view = fmt::detail::std_string_view<TypeParam>;
+ fmt::detail::is_string<derived_from_string_view<TypeParam>>::value);
+ using string_view = fmt::detail::std_string_view<TypeParam>;
EXPECT_TRUE(std::is_empty<string_view>::value !=
- fmt::detail::is_string<string_view>::value);
- EXPECT_TRUE(fmt::detail::is_string<my_ns::my_string<TypeParam>>::value);
- EXPECT_FALSE(fmt::detail::is_string<my_ns::non_string>::value);
+ fmt::detail::is_string<string_view>::value);
+ EXPECT_TRUE(fmt::detail::is_string<my_ns::my_string<TypeParam>>::value);
+ EXPECT_FALSE(fmt::detail::is_string<my_ns::non_string>::value);
}
TEST(CoreTest, Format) {
@@ -716,10 +716,10 @@ TEST(CoreTest, FormatTo) {
TEST(CoreTest, ToStringViewForeignStrings) {
using namespace my_ns;
EXPECT_EQ(to_string_view(my_string<char>("42")), "42");
- fmt::detail::type type =
- fmt::detail::mapped_type_constant<my_string<char>,
- fmt::format_context>::value;
- EXPECT_EQ(type, fmt::detail::type::string_type);
+ fmt::detail::type type =
+ fmt::detail::mapped_type_constant<my_string<char>,
+ fmt::format_context>::value;
+ EXPECT_EQ(type, fmt::detail::type::string_type);
}
TEST(CoreTest, FormatForeignStrings) {
@@ -735,7 +735,7 @@ struct implicitly_convertible_to_string_view {
operator fmt::string_view() const { return "foo"; }
};
-TEST(CoreTest, FormatImplicitlyConvertibleToStringView) {
+TEST(CoreTest, FormatImplicitlyConvertibleToStringView) {
EXPECT_EQ("foo", fmt::format("{}", implicitly_convertible_to_string_view()));
}
@@ -745,7 +745,7 @@ struct explicitly_convertible_to_string_view {
explicit operator fmt::string_view() const { return "foo"; }
};
-TEST(CoreTest, FormatExplicitlyConvertibleToStringView) {
+TEST(CoreTest, FormatExplicitlyConvertibleToStringView) {
EXPECT_EQ("foo", fmt::format("{}", explicitly_convertible_to_string_view()));
}
@@ -754,7 +754,7 @@ struct explicitly_convertible_to_std_string_view {
explicit operator std::string_view() const { return "foo"; }
};
-TEST(CoreTest, FormatExplicitlyConvertibleToStdStringView) {
+TEST(CoreTest, FormatExplicitlyConvertibleToStdStringView) {
EXPECT_EQ("foo",
fmt::format("{}", explicitly_convertible_to_std_string_view()));
}
@@ -768,6 +768,6 @@ struct disabled_rvalue_conversion {
operator const char*() && = delete;
};
-TEST(CoreTest, DisabledRValueConversion) {
+TEST(CoreTest, DisabledRValueConversion) {
EXPECT_EQ("foo", fmt::format("{}", disabled_rvalue_conversion()));
}
diff --git a/contrib/libs/fmt/test/core-test/ya.make b/contrib/libs/fmt/test/core-test/ya.make
index d425ffd7ca..8c320f4810 100644
--- a/contrib/libs/fmt/test/core-test/ya.make
+++ b/contrib/libs/fmt/test/core-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/format-impl-test.cc b/contrib/libs/fmt/test/format-impl-test.cc
index 3ad5e5c936..66b55b5381 100644
--- a/contrib/libs/fmt/test/format-impl-test.cc
+++ b/contrib/libs/fmt/test/format-impl-test.cc
@@ -19,14 +19,14 @@
#include "gtest-extra.h"
#include "util.h"
-#ifdef _WIN32
-# include <windows.h>
-# undef max
-#endif
+#ifdef _WIN32
+# include <windows.h>
+# undef max
+#endif
-using fmt::detail::bigint;
-using fmt::detail::fp;
-using fmt::detail::max_value;
+using fmt::detail::bigint;
+using fmt::detail::fp;
+using fmt::detail::max_value;
static_assert(!std::is_copy_constructible<bigint>::value, "");
static_assert(!std::is_copy_assignable<bigint>::value, "");
@@ -105,7 +105,7 @@ TEST(BigIntTest, Multiply) {
}
TEST(BigIntTest, Accumulator) {
- fmt::detail::accumulator acc;
+ fmt::detail::accumulator acc;
EXPECT_EQ(acc.lower, 0);
EXPECT_EQ(acc.upper, 0);
acc.upper = 12;
@@ -113,7 +113,7 @@ TEST(BigIntTest, Accumulator) {
EXPECT_EQ(static_cast<uint32_t>(acc), 34);
acc += 56;
EXPECT_EQ(acc.lower, 90);
- acc += fmt::detail::max_value<uint64_t>();
+ acc += fmt::detail::max_value<uint64_t>();
EXPECT_EQ(acc.upper, 13);
EXPECT_EQ(acc.lower, 89);
acc >>= 32;
@@ -212,58 +212,58 @@ TEST(FPTest, Multiply) {
}
TEST(FPTest, GetCachedPower) {
- using limits = std::numeric_limits<double>;
+ using limits = std::numeric_limits<double>;
for (auto exp = limits::min_exponent; exp <= limits::max_exponent; ++exp) {
int dec_exp = 0;
- auto fp = fmt::detail::get_cached_power(exp, dec_exp);
- bigint exact, cache(fp.f);
- if (dec_exp >= 0) {
- exact.assign_pow10(dec_exp);
- if (fp.e <= 0)
- exact <<= -fp.e;
- else
- cache <<= fp.e;
- exact.align(cache);
- cache.align(exact);
- auto exact_str = fmt::format("{}", exact);
- auto cache_str = fmt::format("{}", cache);
- EXPECT_EQ(exact_str.size(), cache_str.size());
- EXPECT_EQ(exact_str.substr(0, 15), cache_str.substr(0, 15));
- int diff = cache_str[15] - exact_str[15];
- if (diff == 1)
- EXPECT_GT(exact_str[16], '8');
- else
- EXPECT_EQ(diff, 0);
- } else {
- cache.assign_pow10(-dec_exp);
- cache *= fp.f + 1; // Inexact check.
- exact.assign(1);
- exact <<= -fp.e;
- exact.align(cache);
- auto exact_str = fmt::format("{}", exact);
- auto cache_str = fmt::format("{}", cache);
- EXPECT_EQ(exact_str.size(), cache_str.size());
- EXPECT_EQ(exact_str.substr(0, 16), cache_str.substr(0, 16));
- }
+ auto fp = fmt::detail::get_cached_power(exp, dec_exp);
+ bigint exact, cache(fp.f);
+ if (dec_exp >= 0) {
+ exact.assign_pow10(dec_exp);
+ if (fp.e <= 0)
+ exact <<= -fp.e;
+ else
+ cache <<= fp.e;
+ exact.align(cache);
+ cache.align(exact);
+ auto exact_str = fmt::format("{}", exact);
+ auto cache_str = fmt::format("{}", cache);
+ EXPECT_EQ(exact_str.size(), cache_str.size());
+ EXPECT_EQ(exact_str.substr(0, 15), cache_str.substr(0, 15));
+ int diff = cache_str[15] - exact_str[15];
+ if (diff == 1)
+ EXPECT_GT(exact_str[16], '8');
+ else
+ EXPECT_EQ(diff, 0);
+ } else {
+ cache.assign_pow10(-dec_exp);
+ cache *= fp.f + 1; // Inexact check.
+ exact.assign(1);
+ exact <<= -fp.e;
+ exact.align(cache);
+ auto exact_str = fmt::format("{}", exact);
+ auto cache_str = fmt::format("{}", cache);
+ EXPECT_EQ(exact_str.size(), cache_str.size());
+ EXPECT_EQ(exact_str.substr(0, 16), cache_str.substr(0, 16));
+ }
}
}
-TEST(FPTest, DragonboxMaxK) {
- using fmt::detail::dragonbox::floor_log10_pow2;
- using float_info = fmt::detail::dragonbox::float_info<float>;
- EXPECT_EQ(fmt::detail::const_check(float_info::max_k),
- float_info::kappa - floor_log10_pow2(float_info::min_exponent -
- float_info::significand_bits));
- using double_info = fmt::detail::dragonbox::float_info<double>;
- EXPECT_EQ(
- fmt::detail::const_check(double_info::max_k),
- double_info::kappa - floor_log10_pow2(double_info::min_exponent -
- double_info::significand_bits));
-}
-
+TEST(FPTest, DragonboxMaxK) {
+ using fmt::detail::dragonbox::floor_log10_pow2;
+ using float_info = fmt::detail::dragonbox::float_info<float>;
+ EXPECT_EQ(fmt::detail::const_check(float_info::max_k),
+ float_info::kappa - floor_log10_pow2(float_info::min_exponent -
+ float_info::significand_bits));
+ using double_info = fmt::detail::dragonbox::float_info<double>;
+ EXPECT_EQ(
+ fmt::detail::const_check(double_info::max_k),
+ double_info::kappa - floor_log10_pow2(double_info::min_exponent -
+ double_info::significand_bits));
+}
+
TEST(FPTest, GetRoundDirection) {
- using fmt::detail::get_round_direction;
- using fmt::detail::round_direction;
+ using fmt::detail::get_round_direction;
+ using fmt::detail::round_direction;
EXPECT_EQ(round_direction::down, get_round_direction(100, 50, 0));
EXPECT_EQ(round_direction::up, get_round_direction(100, 51, 0));
EXPECT_EQ(round_direction::down, get_round_direction(100, 40, 10));
@@ -286,9 +286,9 @@ TEST(FPTest, GetRoundDirection) {
}
TEST(FPTest, FixedHandler) {
- struct handler : fmt::detail::fixed_handler {
+ struct handler : fmt::detail::fixed_handler {
char buffer[10];
- handler(int prec = 0) : fmt::detail::fixed_handler() {
+ handler(int prec = 0) : fmt::detail::fixed_handler() {
buf = buffer;
precision = prec;
}
@@ -297,8 +297,8 @@ TEST(FPTest, FixedHandler) {
handler().on_digit('0', 100, 99, 0, exp, false);
EXPECT_THROW(handler().on_digit('0', 100, 100, 0, exp, false),
assertion_failure);
- namespace digits = fmt::detail::digits;
- EXPECT_EQ(handler(1).on_digit('0', 100, 10, 10, exp, false), digits::error);
+ namespace digits = fmt::detail::digits;
+ EXPECT_EQ(handler(1).on_digit('0', 100, 10, 10, exp, false), digits::error);
// Check that divisor - error doesn't overflow.
EXPECT_EQ(handler(1).on_digit('0', 100, 10, 101, exp, false), digits::error);
// Check that 2 * error doesn't overflow.
@@ -309,7 +309,7 @@ TEST(FPTest, FixedHandler) {
TEST(FPTest, GrisuFormatCompilesWithNonIEEEDouble) {
fmt::memory_buffer buf;
- format_float(0.42, -1, fmt::detail::float_specs(), buf);
+ format_float(0.42, -1, fmt::detail::float_specs(), buf);
}
template <typename T> struct value_extractor {
@@ -321,11 +321,11 @@ template <typename T> struct value_extractor {
#if FMT_USE_INT128
// Apple Clang does not define typeid for __int128_t and __uint128_t.
- FMT_NORETURN T operator()(fmt::detail::int128_t) {
+ FMT_NORETURN T operator()(fmt::detail::int128_t) {
throw std::runtime_error("invalid type __int128_t");
}
- FMT_NORETURN T operator()(fmt::detail::uint128_t) {
+ FMT_NORETURN T operator()(fmt::detail::uint128_t) {
throw std::runtime_error("invalid type __uint128_t");
}
#endif
@@ -333,9 +333,9 @@ template <typename T> struct value_extractor {
TEST(FormatTest, ArgConverter) {
long long value = max_value<long long>();
- auto arg = fmt::detail::make_arg<fmt::format_context>(value);
+ auto arg = fmt::detail::make_arg<fmt::format_context>(value);
fmt::visit_format_arg(
- fmt::detail::arg_converter<long long, fmt::format_context>(arg, 'd'),
+ fmt::detail::arg_converter<long long, fmt::format_context>(arg, 'd'),
arg);
EXPECT_EQ(value, fmt::visit_format_arg(value_extractor<long long>(), arg));
}
@@ -343,9 +343,9 @@ TEST(FormatTest, ArgConverter) {
TEST(FormatTest, StrError) {
char* message = nullptr;
char buffer[BUFFER_SIZE];
- EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = nullptr, 0),
+ EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = nullptr, 0),
"invalid buffer");
- EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = buffer, 0),
+ EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = buffer, 0),
"invalid buffer");
buffer[0] = 'x';
#if defined(_GNU_SOURCE) && !defined(__COVERITY__)
@@ -357,18 +357,18 @@ TEST(FormatTest, StrError) {
#endif
int result =
- fmt::detail::safe_strerror(error_code, message = buffer, BUFFER_SIZE);
+ fmt::detail::safe_strerror(error_code, message = buffer, BUFFER_SIZE);
EXPECT_EQ(result, 0);
- size_t message_size = std::strlen(message);
+ size_t message_size = std::strlen(message);
EXPECT_GE(BUFFER_SIZE - 1u, message_size);
EXPECT_EQ(get_system_error(error_code), message);
// safe_strerror never uses buffer on MinGW.
#if !defined(__MINGW32__) && !defined(__sun)
result =
- fmt::detail::safe_strerror(error_code, message = buffer, message_size);
+ fmt::detail::safe_strerror(error_code, message = buffer, message_size);
EXPECT_EQ(ERANGE, result);
- result = fmt::detail::safe_strerror(error_code, message = buffer, 1);
+ result = fmt::detail::safe_strerror(error_code, message = buffer, 1);
EXPECT_EQ(buffer, message); // Message should point to buffer.
EXPECT_EQ(ERANGE, result);
EXPECT_STREQ("", message);
@@ -380,48 +380,48 @@ TEST(FormatTest, FormatErrorCode) {
{
fmt::memory_buffer buffer;
format_to(buffer, "garbage");
- fmt::detail::format_error_code(buffer, 42, "test");
+ fmt::detail::format_error_code(buffer, 42, "test");
EXPECT_EQ("test: " + msg, to_string(buffer));
}
{
fmt::memory_buffer buffer;
std::string prefix(fmt::inline_buffer_size - msg.size() - sep.size() + 1,
'x');
- fmt::detail::format_error_code(buffer, 42, prefix);
+ fmt::detail::format_error_code(buffer, 42, prefix);
EXPECT_EQ(msg, to_string(buffer));
}
int codes[] = {42, -1};
- for (size_t i = 0, n = sizeof(codes) / sizeof(*codes); i < n; ++i) {
+ for (size_t i = 0, n = sizeof(codes) / sizeof(*codes); i < n; ++i) {
// Test maximum buffer size.
msg = fmt::format("error {}", codes[i]);
fmt::memory_buffer buffer;
std::string prefix(fmt::inline_buffer_size - msg.size() - sep.size(), 'x');
- fmt::detail::format_error_code(buffer, codes[i], prefix);
+ fmt::detail::format_error_code(buffer, codes[i], prefix);
EXPECT_EQ(prefix + sep + msg, to_string(buffer));
- size_t size = fmt::inline_buffer_size;
+ size_t size = fmt::inline_buffer_size;
EXPECT_EQ(size, buffer.size());
buffer.resize(0);
// Test with a message that doesn't fit into the buffer.
prefix += 'x';
- fmt::detail::format_error_code(buffer, codes[i], prefix);
+ fmt::detail::format_error_code(buffer, codes[i], prefix);
EXPECT_EQ(msg, to_string(buffer));
}
}
TEST(FormatTest, CountCodePoints) {
- EXPECT_EQ(4,
- fmt::detail::count_code_points(
- fmt::basic_string_view<fmt::detail::char8_type>(
- reinterpret_cast<const fmt::detail::char8_type*>("ёжик"))));
+ EXPECT_EQ(4,
+ fmt::detail::count_code_points(
+ fmt::basic_string_view<fmt::detail::char8_type>(
+ reinterpret_cast<const fmt::detail::char8_type*>("ёжик"))));
}
-// Tests fmt::detail::count_digits for integer type Int.
+// Tests fmt::detail::count_digits for integer type Int.
template <typename Int> void test_count_digits() {
- for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::detail::count_digits(i));
+ for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::detail::count_digits(i));
for (Int i = 1, n = 1, end = max_value<Int>() / 10; n <= end; ++i) {
n *= 10;
- EXPECT_EQ(i, fmt::detail::count_digits(n - 1));
- EXPECT_EQ(i + 1, fmt::detail::count_digits(n));
+ EXPECT_EQ(i, fmt::detail::count_digits(n - 1));
+ EXPECT_EQ(i + 1, fmt::detail::count_digits(n));
}
}
@@ -430,17 +430,17 @@ TEST(UtilTest, CountDigits) {
test_count_digits<uint64_t>();
}
-TEST(UtilTest, WriteFallbackUIntPtr) {
- std::string s;
- fmt::detail::write_ptr<char>(
- std::back_inserter(s),
- fmt::detail::fallback_uintptr(reinterpret_cast<void*>(0xface)), nullptr);
- EXPECT_EQ(s, "0xface");
+TEST(UtilTest, WriteFallbackUIntPtr) {
+ std::string s;
+ fmt::detail::write_ptr<char>(
+ std::back_inserter(s),
+ fmt::detail::fallback_uintptr(reinterpret_cast<void*>(0xface)), nullptr);
+ EXPECT_EQ(s, "0xface");
}
-
-#ifdef _WIN32
-TEST(UtilTest, WriteConsoleSignature) {
- decltype(WriteConsoleW)* p = fmt::detail::WriteConsoleW;
- (void)p;
-}
-#endif
+
+#ifdef _WIN32
+TEST(UtilTest, WriteConsoleSignature) {
+ decltype(WriteConsoleW)* p = fmt::detail::WriteConsoleW;
+ (void)p;
+}
+#endif
diff --git a/contrib/libs/fmt/test/format-impl-test/ya.make b/contrib/libs/fmt/test/format-impl-test/ya.make
index 8ca5470ce0..f8612f4120 100644
--- a/contrib/libs/fmt/test/format-impl-test/ya.make
+++ b/contrib/libs/fmt/test/format-impl-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/format-test.cc b/contrib/libs/fmt/test/format-test.cc
index 1059d6ba64..6164ad60d6 100644
--- a/contrib/libs/fmt/test/format-test.cc
+++ b/contrib/libs/fmt/test/format-test.cc
@@ -42,7 +42,7 @@ using fmt::memory_buffer;
using fmt::string_view;
using fmt::wmemory_buffer;
using fmt::wstring_view;
-using fmt::detail::max_value;
+using fmt::detail::max_value;
using testing::Return;
using testing::StrictMock;
@@ -103,10 +103,10 @@ struct uint32_pair {
};
TEST(UtilTest, BitCast) {
- auto s = fmt::detail::bit_cast<uint32_pair>(uint64_t{42});
- EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), 42ull);
- s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
- EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), ~0ull);
+ auto s = fmt::detail::bit_cast<uint32_pair>(uint64_t{42});
+ EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), 42ull);
+ s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
+ EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), ~0ull);
}
TEST(UtilTest, Increment) {
@@ -131,27 +131,27 @@ TEST(UtilTest, ParseNonnegativeInt) {
fmt::string_view s = "10000000000";
auto begin = s.begin(), end = s.end();
EXPECT_THROW_MSG(
- parse_nonnegative_int(begin, end, fmt::detail::error_handler()),
+ parse_nonnegative_int(begin, end, fmt::detail::error_handler()),
fmt::format_error, "number is too big");
s = "2147483649";
begin = s.begin();
end = s.end();
EXPECT_THROW_MSG(
- parse_nonnegative_int(begin, end, fmt::detail::error_handler()),
+ parse_nonnegative_int(begin, end, fmt::detail::error_handler()),
fmt::format_error, "number is too big");
}
TEST(IteratorTest, CountingIterator) {
- fmt::detail::counting_iterator it;
+ fmt::detail::counting_iterator it;
auto prev = it++;
EXPECT_EQ(prev.count(), 0);
EXPECT_EQ(it.count(), 1);
- EXPECT_EQ((it + 41).count(), 42);
+ EXPECT_EQ((it + 41).count(), 42);
}
TEST(IteratorTest, TruncatingIterator) {
char* p = nullptr;
- fmt::detail::truncating_iterator<char*> it(p, 3);
+ fmt::detail::truncating_iterator<char*> it(p, 3);
auto prev = it++;
EXPECT_EQ(prev.base(), p);
EXPECT_EQ(it.base(), p + 1);
@@ -160,7 +160,7 @@ TEST(IteratorTest, TruncatingIterator) {
TEST(IteratorTest, TruncatingBackInserter) {
std::string buffer;
auto bi = std::back_inserter(buffer);
- fmt::detail::truncating_iterator<decltype(bi)> it(bi, 2);
+ fmt::detail::truncating_iterator<decltype(bi)> it(bi, 2);
*it++ = '4';
*it++ = '2';
*it++ = '1';
@@ -169,22 +169,22 @@ TEST(IteratorTest, TruncatingBackInserter) {
}
TEST(IteratorTest, IsOutputIterator) {
- EXPECT_TRUE((fmt::detail::is_output_iterator<char*, char>::value));
- EXPECT_FALSE((fmt::detail::is_output_iterator<const char*, char>::value));
- EXPECT_FALSE((fmt::detail::is_output_iterator<std::string, char>::value));
+ EXPECT_TRUE((fmt::detail::is_output_iterator<char*, char>::value));
+ EXPECT_FALSE((fmt::detail::is_output_iterator<const char*, char>::value));
+ EXPECT_FALSE((fmt::detail::is_output_iterator<std::string, char>::value));
EXPECT_TRUE(
- (fmt::detail::is_output_iterator<std::back_insert_iterator<std::string>,
- char>::value));
- EXPECT_TRUE(
- (fmt::detail::is_output_iterator<std::string::iterator, char>::value));
- EXPECT_FALSE((fmt::detail::is_output_iterator<std::string::const_iterator,
- char>::value));
- EXPECT_FALSE((fmt::detail::is_output_iterator<std::list<char>, char>::value));
- EXPECT_TRUE((
- fmt::detail::is_output_iterator<std::list<char>::iterator, char>::value));
- EXPECT_FALSE((fmt::detail::is_output_iterator<std::list<char>::const_iterator,
- char>::value));
- EXPECT_FALSE((fmt::detail::is_output_iterator<uint32_pair, char>::value));
+ (fmt::detail::is_output_iterator<std::back_insert_iterator<std::string>,
+ char>::value));
+ EXPECT_TRUE(
+ (fmt::detail::is_output_iterator<std::string::iterator, char>::value));
+ EXPECT_FALSE((fmt::detail::is_output_iterator<std::string::const_iterator,
+ char>::value));
+ EXPECT_FALSE((fmt::detail::is_output_iterator<std::list<char>, char>::value));
+ EXPECT_TRUE((
+ fmt::detail::is_output_iterator<std::list<char>::iterator, char>::value));
+ EXPECT_FALSE((fmt::detail::is_output_iterator<std::list<char>::const_iterator,
+ char>::value));
+ EXPECT_FALSE((fmt::detail::is_output_iterator<uint32_pair, char>::value));
}
TEST(MemoryBufferTest, Ctor) {
@@ -238,7 +238,7 @@ TEST(MemoryBufferTest, MoveCtorInlineBuffer) {
std::allocator<char> alloc;
basic_memory_buffer<char, 5, TestAllocator> buffer((TestAllocator(&alloc)));
const char test[] = "test";
- buffer.append(string_view(test, 4));
+ buffer.append(string_view(test, 4));
check_move_buffer("test", buffer);
// Adding one more character fills the inline buffer, but doesn't cause
// dynamic allocation.
@@ -296,15 +296,15 @@ TEST(MemoryBufferTest, MoveAssignment) {
TEST(MemoryBufferTest, Grow) {
typedef allocator_ref<mock_allocator<int>> Allocator;
mock_allocator<int> alloc;
- basic_memory_buffer<int, 10, Allocator> buffer((Allocator(&alloc)));
+ basic_memory_buffer<int, 10, Allocator> buffer((Allocator(&alloc)));
buffer.resize(7);
- using fmt::detail::to_unsigned;
+ using fmt::detail::to_unsigned;
for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i;
EXPECT_EQ(10u, buffer.capacity());
int mem[20];
mem[7] = 0xdead;
EXPECT_CALL(alloc, allocate(20)).WillOnce(Return(mem));
- buffer.try_reserve(20);
+ buffer.try_reserve(20);
EXPECT_EQ(20u, buffer.capacity());
// Check if size elements have been copied
for (int i = 0; i < 7; ++i) EXPECT_EQ(i * i, buffer[to_unsigned(i)]);
@@ -323,7 +323,7 @@ TEST(MemoryBufferTest, Allocator) {
basic_memory_buffer<char, 10, TestAllocator> buffer2(
(TestAllocator(&alloc)));
EXPECT_EQ(&alloc, buffer2.get_allocator().get());
- size_t size = 2 * fmt::inline_buffer_size;
+ size_t size = 2 * fmt::inline_buffer_size;
EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem));
buffer2.reserve(size);
EXPECT_CALL(alloc, deallocate(&mem, size));
@@ -334,7 +334,7 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) {
typedef allocator_ref<mock_allocator<char>> TestAllocator;
StrictMock<mock_allocator<char>> alloc;
basic_memory_buffer<char, 10, TestAllocator> buffer((TestAllocator(&alloc)));
- size_t size = 2 * fmt::inline_buffer_size;
+ size_t size = 2 * fmt::inline_buffer_size;
std::vector<char> mem(size);
{
EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem[0]));
@@ -349,27 +349,27 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) {
EXPECT_THROW(buffer.reserve(2 * size), std::exception);
EXPECT_EQ(&mem2[0], &buffer[0]);
// Check that the data has been copied.
- for (size_t i = 0; i < size; ++i) EXPECT_EQ('x', buffer[i]);
+ for (size_t i = 0; i < size; ++i) EXPECT_EQ('x', buffer[i]);
}
EXPECT_CALL(alloc, deallocate(&mem2[0], 2 * size));
}
TEST(UtilTest, UTF8ToUTF16) {
- fmt::detail::utf8_to_utf16 u("лошадка");
+ fmt::detail::utf8_to_utf16 u("лошадка");
EXPECT_EQ(L"\x043B\x043E\x0448\x0430\x0434\x043A\x0430", u.str());
EXPECT_EQ(7, u.size());
// U+10437 { DESERET SMALL LETTER YEE }
- EXPECT_EQ(L"\xD801\xDC37", fmt::detail::utf8_to_utf16("𐐷").str());
- EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16("\xc3\x28"), std::runtime_error,
+ EXPECT_EQ(L"\xD801\xDC37", fmt::detail::utf8_to_utf16("𐐷").str());
+ EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16("\xc3\x28"), std::runtime_error,
"invalid utf8");
- EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16(fmt::string_view("л", 1)),
+ EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16(fmt::string_view("л", 1)),
std::runtime_error, "invalid utf8");
- EXPECT_EQ(L"123456", fmt::detail::utf8_to_utf16("123456").str());
+ EXPECT_EQ(L"123456", fmt::detail::utf8_to_utf16("123456").str());
}
TEST(UtilTest, UTF8ToUTF16EmptyString) {
std::string s = "";
- fmt::detail::utf8_to_utf16 u(s.c_str());
+ fmt::detail::utf8_to_utf16 u(s.c_str());
EXPECT_EQ(L"", u.str());
EXPECT_EQ(s.size(), u.size());
}
@@ -497,14 +497,14 @@ TEST(FormatterTest, ArgErrors) {
EXPECT_THROW_MSG(format("{"), format_error, "invalid format string");
EXPECT_THROW_MSG(format("{?}"), format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0"), format_error, "invalid format string");
- EXPECT_THROW_MSG(format("{0}"), format_error, "argument not found");
+ EXPECT_THROW_MSG(format("{0}"), format_error, "argument not found");
EXPECT_THROW_MSG(format("{00}", 42), format_error, "invalid format string");
char format_str[BUFFER_SIZE];
safe_sprintf(format_str, "{%u", INT_MAX);
EXPECT_THROW_MSG(format(format_str), format_error, "invalid format string");
safe_sprintf(format_str, "{%u}", INT_MAX);
- EXPECT_THROW_MSG(format(format_str), format_error, "argument not found");
+ EXPECT_THROW_MSG(format(format_str), format_error, "argument not found");
safe_sprintf(format_str, "{%u", INT_MAX + 1u);
EXPECT_THROW_MSG(format(format_str), format_error, "number is too big");
@@ -529,13 +529,13 @@ template <> struct TestFormat<0> {
TEST(FormatterTest, ManyArgs) {
EXPECT_EQ("19", TestFormat<20>::format("{19}"));
EXPECT_THROW_MSG(TestFormat<20>::format("{20}"), format_error,
- "argument not found");
+ "argument not found");
EXPECT_THROW_MSG(TestFormat<21>::format("{21}"), format_error,
- "argument not found");
- enum { max_packed_args = fmt::detail::max_packed_args };
+ "argument not found");
+ enum { max_packed_args = fmt::detail::max_packed_args };
std::string format_str = fmt::format("{{{}}}", max_packed_args + 1);
EXPECT_THROW_MSG(TestFormat<max_packed_args>::format(format_str),
- format_error, "argument not found");
+ format_error, "argument not found");
}
TEST(FormatterTest, NamedArg) {
@@ -550,8 +550,8 @@ TEST(FormatterTest, NamedArg) {
fmt::arg("i", 0), fmt::arg("j", 0), fmt::arg("k", 0),
fmt::arg("l", 0), fmt::arg("m", 0), fmt::arg("n", 0),
fmt::arg("o", 0), fmt::arg("p", 0)));
- EXPECT_THROW_MSG(format("{a}"), format_error, "argument not found");
- EXPECT_THROW_MSG(format("{a}", 42), format_error, "argument not found");
+ EXPECT_THROW_MSG(format("{a}"), format_error, "argument not found");
+ EXPECT_THROW_MSG(format("{a}", 42), format_error, "argument not found");
}
TEST(FormatterTest, AutoArgIndex) {
@@ -565,7 +565,7 @@ TEST(FormatterTest, AutoArgIndex) {
"cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{:.{0}}", 1.2345, 2), format_error,
"cannot switch from automatic to manual argument indexing");
- EXPECT_THROW_MSG(format("{}"), format_error, "argument not found");
+ EXPECT_THROW_MSG(format("{}"), format_error, "argument not found");
}
TEST(FormatterTest, EmptySpecs) { EXPECT_EQ("42", format("{0:}", 42)); }
@@ -580,8 +580,8 @@ TEST(FormatterTest, LeftAlign) {
EXPECT_EQ("42 ", format("{0:<5}", 42ul));
EXPECT_EQ("-42 ", format("{0:<5}", -42ll));
EXPECT_EQ("42 ", format("{0:<5}", 42ull));
- EXPECT_EQ("-42 ", format("{0:<5}", -42.0));
- EXPECT_EQ("-42 ", format("{0:<5}", -42.0l));
+ EXPECT_EQ("-42 ", format("{0:<5}", -42.0));
+ EXPECT_EQ("-42 ", format("{0:<5}", -42.0l));
EXPECT_EQ("c ", format("{0:<5}", 'c'));
EXPECT_EQ("abc ", format("{0:<5}", "abc"));
EXPECT_EQ("0xface ", format("{0:<8}", reinterpret_cast<void*>(0xface)));
@@ -597,15 +597,15 @@ TEST(FormatterTest, RightAlign) {
EXPECT_EQ(" 42", format("{0:>5}", 42ul));
EXPECT_EQ(" -42", format("{0:>5}", -42ll));
EXPECT_EQ(" 42", format("{0:>5}", 42ull));
- EXPECT_EQ(" -42", format("{0:>5}", -42.0));
- EXPECT_EQ(" -42", format("{0:>5}", -42.0l));
+ EXPECT_EQ(" -42", format("{0:>5}", -42.0));
+ EXPECT_EQ(" -42", format("{0:>5}", -42.0l));
EXPECT_EQ(" c", format("{0:>5}", 'c'));
EXPECT_EQ(" abc", format("{0:>5}", "abc"));
EXPECT_EQ(" 0xface", format("{0:>8}", reinterpret_cast<void*>(0xface)));
}
-#if FMT_DEPRECATED_NUMERIC_ALIGN
-TEST(FormatterTest, NumericAlign) { EXPECT_EQ("0042", format("{0:=4}", 42)); }
+#if FMT_DEPRECATED_NUMERIC_ALIGN
+TEST(FormatterTest, NumericAlign) { EXPECT_EQ("0042", format("{0:=4}", 42)); }
#endif
TEST(FormatterTest, CenterAlign) {
@@ -618,8 +618,8 @@ TEST(FormatterTest, CenterAlign) {
EXPECT_EQ(" 42 ", format("{0:^5}", 42ul));
EXPECT_EQ(" -42 ", format("{0:^5}", -42ll));
EXPECT_EQ(" 42 ", format("{0:^5}", 42ull));
- EXPECT_EQ(" -42 ", format("{0:^5}", -42.0));
- EXPECT_EQ(" -42 ", format("{0:^5}", -42.0l));
+ EXPECT_EQ(" -42 ", format("{0:^5}", -42.0));
+ EXPECT_EQ(" -42 ", format("{0:^5}", -42.0l));
EXPECT_EQ(" c ", format("{0:^5}", 'c'));
EXPECT_EQ(" abc ", format("{0:^6}", "abc"));
EXPECT_EQ(" 0xface ", format("{0:^8}", reinterpret_cast<void*>(0xface)));
@@ -637,8 +637,8 @@ TEST(FormatterTest, Fill) {
EXPECT_EQ("***42", format("{0:*>5}", 42ul));
EXPECT_EQ("**-42", format("{0:*>5}", -42ll));
EXPECT_EQ("***42", format("{0:*>5}", 42ull));
- EXPECT_EQ("**-42", format("{0:*>5}", -42.0));
- EXPECT_EQ("**-42", format("{0:*>5}", -42.0l));
+ EXPECT_EQ("**-42", format("{0:*>5}", -42.0));
+ EXPECT_EQ("**-42", format("{0:*>5}", -42.0l));
EXPECT_EQ("c****", format("{0:*<5}", 'c'));
EXPECT_EQ("abc**", format("{0:*<5}", "abc"));
EXPECT_EQ("**0xface", format("{0:*>8}", reinterpret_cast<void*>(0xface)));
@@ -646,7 +646,7 @@ TEST(FormatterTest, Fill) {
EXPECT_EQ(std::string("\0\0\0*", 4), format(string_view("{:\0>4}", 6), '*'));
EXPECT_EQ("жж42", format("{0:ж>4}", 42));
EXPECT_THROW_MSG(format("{:\x80\x80\x80\x80\x80>}", 0), format_error,
- "missing '}' in format string");
+ "missing '}' in format string");
}
TEST(FormatterTest, PlusSign) {
@@ -661,8 +661,8 @@ TEST(FormatterTest, PlusSign) {
EXPECT_EQ("+42", format("{0:+}", 42ll));
EXPECT_THROW_MSG(format("{0:+}", 42ull), format_error,
"format specifier requires signed argument");
- EXPECT_EQ("+42", format("{0:+}", 42.0));
- EXPECT_EQ("+42", format("{0:+}", 42.0l));
+ EXPECT_EQ("+42", format("{0:+}", 42.0));
+ EXPECT_EQ("+42", format("{0:+}", 42.0l));
EXPECT_THROW_MSG(format("{0:+", 'c'), format_error,
"missing '}' in format string");
EXPECT_THROW_MSG(format("{0:+}", 'c'), format_error,
@@ -685,8 +685,8 @@ TEST(FormatterTest, MinusSign) {
EXPECT_EQ("42", format("{0:-}", 42ll));
EXPECT_THROW_MSG(format("{0:-}", 42ull), format_error,
"format specifier requires signed argument");
- EXPECT_EQ("42", format("{0:-}", 42.0));
- EXPECT_EQ("42", format("{0:-}", 42.0l));
+ EXPECT_EQ("42", format("{0:-}", 42.0));
+ EXPECT_EQ("42", format("{0:-}", 42.0l));
EXPECT_THROW_MSG(format("{0:-", 'c'), format_error,
"missing '}' in format string");
EXPECT_THROW_MSG(format("{0:-}", 'c'), format_error,
@@ -709,8 +709,8 @@ TEST(FormatterTest, SpaceSign) {
EXPECT_EQ(" 42", format("{0: }", 42ll));
EXPECT_THROW_MSG(format("{0: }", 42ull), format_error,
"format specifier requires signed argument");
- EXPECT_EQ(" 42", format("{0: }", 42.0));
- EXPECT_EQ(" 42", format("{0: }", 42.0l));
+ EXPECT_EQ(" 42", format("{0: }", 42.0));
+ EXPECT_EQ(" 42", format("{0: }", 42.0l));
EXPECT_THROW_MSG(format("{0: ", 'c'), format_error,
"missing '}' in format string");
EXPECT_THROW_MSG(format("{0: }", 'c'), format_error,
@@ -721,12 +721,12 @@ TEST(FormatterTest, SpaceSign) {
"format specifier requires numeric argument");
}
-TEST(FormatterTest, SignNotTruncated) {
- wchar_t format_str[] = {L'{', L':',
- '+' | (1 << fmt::detail::num_bits<char>()), L'}', 0};
- EXPECT_THROW(format(format_str, 42), format_error);
-}
-
+TEST(FormatterTest, SignNotTruncated) {
+ wchar_t format_str[] = {L'{', L':',
+ '+' | (1 << fmt::detail::num_bits<char>()), L'}', 0};
+ EXPECT_THROW(format(format_str, 42), format_error);
+}
+
TEST(FormatterTest, HashFlag) {
EXPECT_EQ("42", format("{0:#}", 42));
EXPECT_EQ("-42", format("{0:#}", -42));
@@ -765,8 +765,8 @@ TEST(FormatterTest, HashFlag) {
EXPECT_EQ("-42.0", format("{0:#}", -42.0l));
EXPECT_EQ("4.e+01", format("{:#.0e}", 42.0));
EXPECT_EQ("0.", format("{:#.0f}", 0.01));
- EXPECT_EQ("0.50", format("{:#.2g}", 0.5));
- EXPECT_EQ("0.", format("{:#.0f}", 0.5));
+ EXPECT_EQ("0.50", format("{:#.2g}", 0.5));
+ EXPECT_EQ("0.", format("{:#.0f}", 0.5));
EXPECT_THROW_MSG(format("{0:#", 'c'), format_error,
"missing '}' in format string");
EXPECT_THROW_MSG(format("{0:#}", 'c'), format_error,
@@ -785,8 +785,8 @@ TEST(FormatterTest, ZeroFlag) {
EXPECT_EQ("00042", format("{0:05}", 42ul));
EXPECT_EQ("-0042", format("{0:05}", -42ll));
EXPECT_EQ("00042", format("{0:05}", 42ull));
- EXPECT_EQ("-000042", format("{0:07}", -42.0));
- EXPECT_EQ("-000042", format("{0:07}", -42.0l));
+ EXPECT_EQ("-000042", format("{0:07}", -42.0));
+ EXPECT_EQ("-000042", format("{0:07}", -42.0l));
EXPECT_THROW_MSG(format("{0:0", 'c'), format_error,
"missing '}' in format string");
EXPECT_THROW_MSG(format("{0:05}", 'c'), format_error,
@@ -802,7 +802,7 @@ TEST(FormatterTest, Width) {
safe_sprintf(format_str, "{0:%u", UINT_MAX);
increment(format_str + 3);
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
- size_t size = std::strlen(format_str);
+ size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
@@ -832,7 +832,7 @@ TEST(FormatterTest, RuntimeWidth) {
safe_sprintf(format_str, "{0:{%u", UINT_MAX);
increment(format_str + 4);
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
- size_t size = std::strlen(format_str);
+ size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
@@ -844,7 +844,7 @@ TEST(FormatterTest, RuntimeWidth) {
EXPECT_THROW_MSG(format("{0:{}", 0), format_error,
"cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{0:{?}}", 0), format_error, "invalid format string");
- EXPECT_THROW_MSG(format("{0:{1}}", 0), format_error, "argument not found");
+ EXPECT_THROW_MSG(format("{0:{1}}", 0), format_error, "argument not found");
EXPECT_THROW_MSG(format("{0:{0:}}", 0), format_error,
"invalid format string");
@@ -885,7 +885,7 @@ TEST(FormatterTest, Precision) {
safe_sprintf(format_str, "{0:.%u", UINT_MAX);
increment(format_str + 4);
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
- size_t size = std::strlen(format_str);
+ size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
@@ -959,9 +959,9 @@ TEST(FormatterTest, Precision) {
EXPECT_EQ("123.", format("{:#.0f}", 123.0));
EXPECT_EQ("1.23", format("{:.02f}", 1.234));
EXPECT_EQ("0.001", format("{:.1g}", 0.001));
- EXPECT_EQ("1019666400", format("{}", 1019666432.0f));
- EXPECT_EQ("1e+01", format("{:.0e}", 9.5));
- EXPECT_EQ("1.0e-34", fmt::format("{:.1e}", 1e-34));
+ EXPECT_EQ("1019666400", format("{}", 1019666432.0f));
+ EXPECT_EQ("1e+01", format("{:.0e}", 9.5));
+ EXPECT_EQ("1.0e-34", fmt::format("{:.1e}", 1e-34));
EXPECT_THROW_MSG(format("{0:.2}", reinterpret_cast<void*>(0xcafe)),
format_error,
@@ -969,7 +969,7 @@ TEST(FormatterTest, Precision) {
EXPECT_THROW_MSG(format("{0:.2f}", reinterpret_cast<void*>(0xcafe)),
format_error,
"precision not allowed for this argument type");
- EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::detail::max_value<int>()),
+ EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::detail::max_value<int>()),
format_error, "number is too big");
EXPECT_EQ("st", format("{0:.2}", "str"));
@@ -980,7 +980,7 @@ TEST(FormatterTest, RuntimePrecision) {
safe_sprintf(format_str, "{0:.{%u", UINT_MAX);
increment(format_str + 5);
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
- size_t size = std::strlen(format_str);
+ size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
@@ -995,7 +995,7 @@ TEST(FormatterTest, RuntimePrecision) {
"invalid format string");
EXPECT_THROW_MSG(format("{0:.{1}", 0, 0), format_error,
"precision not allowed for this argument type");
- EXPECT_THROW_MSG(format("{0:.{1}}", 0), format_error, "argument not found");
+ EXPECT_THROW_MSG(format("{0:.{1}}", 0), format_error, "argument not found");
EXPECT_THROW_MSG(format("{0:.{0:}}", 0), format_error,
"invalid format string");
@@ -1090,8 +1090,8 @@ TEST(FormatterTest, FormatShort) {
TEST(FormatterTest, FormatInt) {
EXPECT_THROW_MSG(format("{0:v", 42), format_error,
"missing '}' in format string");
- check_unknown_types(42, "bBdoxXnLc", "integer");
- EXPECT_EQ("x", format("{:c}", static_cast<int>('x')));
+ check_unknown_types(42, "bBdoxXnLc", "integer");
+ EXPECT_EQ("x", format("{:c}", static_cast<int>('x')));
}
TEST(FormatterTest, FormatBin) {
@@ -1243,23 +1243,23 @@ TEST(FormatterTest, FormatConvertibleToLongLong) {
}
TEST(FormatterTest, FormatFloat) {
- EXPECT_EQ("0", format("{}", 0.0f));
+ EXPECT_EQ("0", format("{}", 0.0f));
EXPECT_EQ("392.500000", format("{0:f}", 392.5f));
}
TEST(FormatterTest, FormatDouble) {
- EXPECT_EQ("0", format("{}", 0.0));
- check_unknown_types(1.2, "eEfFgGaAnL%", "double");
- EXPECT_EQ("0", format("{:}", 0.0));
+ EXPECT_EQ("0", format("{}", 0.0));
+ check_unknown_types(1.2, "eEfFgGaAnL%", "double");
+ EXPECT_EQ("0", format("{:}", 0.0));
EXPECT_EQ("0.000000", format("{:f}", 0.0));
EXPECT_EQ("0", format("{:g}", 0.0));
EXPECT_EQ("392.65", format("{:}", 392.65));
EXPECT_EQ("392.65", format("{:g}", 392.65));
EXPECT_EQ("392.65", format("{:G}", 392.65));
- EXPECT_EQ("4.9014e+06", format("{:g}", 4.9014e6));
+ EXPECT_EQ("4.9014e+06", format("{:g}", 4.9014e6));
EXPECT_EQ("392.650000", format("{:f}", 392.65));
EXPECT_EQ("392.650000", format("{:F}", 392.65));
- EXPECT_EQ("42", format("{:L}", 42.0));
+ EXPECT_EQ("42", format("{:L}", 42.0));
char buffer[BUFFER_SIZE];
safe_sprintf(buffer, "%e", 392.65);
EXPECT_EQ(buffer, format("{0:e}", 392.65));
@@ -1270,8 +1270,8 @@ TEST(FormatterTest, FormatDouble) {
EXPECT_EQ(buffer, format("{:a}", -42.0));
safe_sprintf(buffer, "%A", -42.0);
EXPECT_EQ(buffer, format("{:A}", -42.0));
- EXPECT_EQ("9223372036854775808.000000",
- format("{:f}", 9223372036854775807.0));
+ EXPECT_EQ("9223372036854775808.000000",
+ format("{:f}", 9223372036854775807.0));
}
TEST(FormatterTest, PrecisionRounding) {
@@ -1285,42 +1285,42 @@ TEST(FormatterTest, PrecisionRounding) {
EXPECT_EQ("1.000", format("{:.3f}", 0.9999));
EXPECT_EQ("0.00123", format("{:.3}", 0.00123));
EXPECT_EQ("0.1", format("{:.16g}", 0.1));
- EXPECT_EQ("1", fmt::format("{:.0}", 1.0));
- EXPECT_EQ("225.51575035152063720",
- fmt::format("{:.17f}", 225.51575035152064));
- EXPECT_EQ("-761519619559038.2", fmt::format("{:.1f}", -761519619559038.2));
- EXPECT_EQ("1.9156918820264798e-56",
- fmt::format("{}", 1.9156918820264798e-56));
- EXPECT_EQ("0.0000", fmt::format("{:.4f}", 7.2809479766055470e-15));
-
- // Trigger a rounding error in Grisu by a specially chosen number.
- EXPECT_EQ("3788512123356.985352", format("{:f}", 3788512123356.985352));
-}
-
-TEST(FormatterTest, PrettifyFloat) {
- EXPECT_EQ("0.0001", fmt::format("{}", 1e-4));
- EXPECT_EQ("1e-05", fmt::format("{}", 1e-5));
- EXPECT_EQ("1000000000000000", fmt::format("{}", 1e15));
- EXPECT_EQ("1e+16", fmt::format("{}", 1e16));
- EXPECT_EQ("9.999e-05", fmt::format("{}", 9.999e-5));
- EXPECT_EQ("10000000000", fmt::format("{}", 1e10));
- EXPECT_EQ("100000000000", fmt::format("{}", 1e11));
- EXPECT_EQ("12340000000", fmt::format("{}", 1234e7));
- EXPECT_EQ("12.34", fmt::format("{}", 1234e-2));
- EXPECT_EQ("0.001234", fmt::format("{}", 1234e-6));
- EXPECT_EQ("0.1", fmt::format("{}", 0.1f));
- EXPECT_EQ("0.10000000149011612", fmt::format("{}", double(0.1f)));
- EXPECT_EQ("1.3563156e-19", fmt::format("{}", 1.35631564e-19f));
-}
-
+ EXPECT_EQ("1", fmt::format("{:.0}", 1.0));
+ EXPECT_EQ("225.51575035152063720",
+ fmt::format("{:.17f}", 225.51575035152064));
+ EXPECT_EQ("-761519619559038.2", fmt::format("{:.1f}", -761519619559038.2));
+ EXPECT_EQ("1.9156918820264798e-56",
+ fmt::format("{}", 1.9156918820264798e-56));
+ EXPECT_EQ("0.0000", fmt::format("{:.4f}", 7.2809479766055470e-15));
+
+ // Trigger a rounding error in Grisu by a specially chosen number.
+ EXPECT_EQ("3788512123356.985352", format("{:f}", 3788512123356.985352));
+}
+
+TEST(FormatterTest, PrettifyFloat) {
+ EXPECT_EQ("0.0001", fmt::format("{}", 1e-4));
+ EXPECT_EQ("1e-05", fmt::format("{}", 1e-5));
+ EXPECT_EQ("1000000000000000", fmt::format("{}", 1e15));
+ EXPECT_EQ("1e+16", fmt::format("{}", 1e16));
+ EXPECT_EQ("9.999e-05", fmt::format("{}", 9.999e-5));
+ EXPECT_EQ("10000000000", fmt::format("{}", 1e10));
+ EXPECT_EQ("100000000000", fmt::format("{}", 1e11));
+ EXPECT_EQ("12340000000", fmt::format("{}", 1234e7));
+ EXPECT_EQ("12.34", fmt::format("{}", 1234e-2));
+ EXPECT_EQ("0.001234", fmt::format("{}", 1234e-6));
+ EXPECT_EQ("0.1", fmt::format("{}", 0.1f));
+ EXPECT_EQ("0.10000000149011612", fmt::format("{}", double(0.1f)));
+ EXPECT_EQ("1.3563156e-19", fmt::format("{}", 1.35631564e-19f));
+}
+
TEST(FormatterTest, FormatNaN) {
double nan = std::numeric_limits<double>::quiet_NaN();
EXPECT_EQ("nan", format("{}", nan));
EXPECT_EQ("+nan", format("{:+}", nan));
- if (std::signbit(-nan))
- EXPECT_EQ("-nan", format("{}", -nan));
- else
- fmt::print("Warning: compiler doesn't handle negative NaN correctly");
+ if (std::signbit(-nan))
+ EXPECT_EQ("-nan", format("{}", -nan));
+ else
+ fmt::print("Warning: compiler doesn't handle negative NaN correctly");
EXPECT_EQ(" nan", format("{: }", nan));
EXPECT_EQ("NAN", format("{:F}", nan));
EXPECT_EQ("nan ", format("{:<7}", nan));
@@ -1341,7 +1341,7 @@ TEST(FormatterTest, FormatInfinity) {
}
TEST(FormatterTest, FormatLongDouble) {
- EXPECT_EQ("0", format("{0:}", 0.0l));
+ EXPECT_EQ("0", format("{0:}", 0.0l));
EXPECT_EQ("0.000000", format("{0:f}", 0.0l));
EXPECT_EQ("392.65", format("{0:}", 392.65l));
EXPECT_EQ("392.65", format("{0:g}", 392.65l));
@@ -1357,7 +1357,7 @@ TEST(FormatterTest, FormatLongDouble) {
}
TEST(FormatterTest, FormatChar) {
- const char types[] = "cbBdoxXL";
+ const char types[] = "cbBdoxXL";
check_unknown_types('a', types, "char");
EXPECT_EQ("a", format("{0}", 'a'));
EXPECT_EQ("z", format("{0:c}", 'z'));
@@ -1473,46 +1473,46 @@ TEST(FormatterTest, FormatExplicitlyConvertibleToStdStringView) {
}
#endif
-// std::is_constructible is broken in MSVC until version 2015.
-#if !FMT_MSC_VER || FMT_MSC_VER >= 1900
-struct explicitly_convertible_to_wstring_view {
- explicit operator fmt::wstring_view() const { return L"foo"; }
-};
-
-TEST(FormatTest, FormatExplicitlyConvertibleToWStringView) {
- EXPECT_EQ(L"foo",
- fmt::format(L"{}", explicitly_convertible_to_wstring_view()));
-}
-#endif
-
-namespace fake_qt {
-class QString {
- public:
- QString(const wchar_t* s) : s_(std::make_shared<std::wstring>(s)) {}
- const wchar_t* utf16() const FMT_NOEXCEPT { return s_->data(); }
- int size() const FMT_NOEXCEPT { return static_cast<int>(s_->size()); }
-
- private:
- std::shared_ptr<std::wstring> s_;
-};
-
-fmt::basic_string_view<wchar_t> to_string_view(const QString& s) FMT_NOEXCEPT {
- return {s.utf16(), static_cast<size_t>(s.size())};
-}
-} // namespace fake_qt
-
-TEST(FormatTest, FormatForeignStrings) {
- using fake_qt::QString;
- EXPECT_EQ(fmt::format(QString(L"{}"), 42), L"42");
- EXPECT_EQ(fmt::format(QString(L"{}"), QString(L"42")), L"42");
-}
-
+// std::is_constructible is broken in MSVC until version 2015.
+#if !FMT_MSC_VER || FMT_MSC_VER >= 1900
+struct explicitly_convertible_to_wstring_view {
+ explicit operator fmt::wstring_view() const { return L"foo"; }
+};
+
+TEST(FormatTest, FormatExplicitlyConvertibleToWStringView) {
+ EXPECT_EQ(L"foo",
+ fmt::format(L"{}", explicitly_convertible_to_wstring_view()));
+}
+#endif
+
+namespace fake_qt {
+class QString {
+ public:
+ QString(const wchar_t* s) : s_(std::make_shared<std::wstring>(s)) {}
+ const wchar_t* utf16() const FMT_NOEXCEPT { return s_->data(); }
+ int size() const FMT_NOEXCEPT { return static_cast<int>(s_->size()); }
+
+ private:
+ std::shared_ptr<std::wstring> s_;
+};
+
+fmt::basic_string_view<wchar_t> to_string_view(const QString& s) FMT_NOEXCEPT {
+ return {s.utf16(), static_cast<size_t>(s.size())};
+}
+} // namespace fake_qt
+
+TEST(FormatTest, FormatForeignStrings) {
+ using fake_qt::QString;
+ EXPECT_EQ(fmt::format(QString(L"{}"), 42), L"42");
+ EXPECT_EQ(fmt::format(QString(L"{}"), QString(L"42")), L"42");
+}
+
FMT_BEGIN_NAMESPACE
template <> struct formatter<Date> {
template <typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
auto it = ctx.begin();
- if (it != ctx.end() && *it == 'd') ++it;
+ if (it != ctx.end() && *it == 'd') ++it;
return it;
}
@@ -1548,7 +1548,7 @@ TEST(FormatterTest, CustomFormat) {
TEST(FormatterTest, CustomFormatTo) {
char buf[10] = {};
auto end =
- &*fmt::format_to(fmt::detail::make_checked(buf, 10), "{}", Answer());
+ &*fmt::format_to(fmt::detail::make_checked(buf, 10), "{}", Answer());
EXPECT_EQ(end, buf + 2);
EXPECT_STREQ(buf, "42");
}
@@ -1558,7 +1558,7 @@ TEST(FormatterTest, WideFormatString) {
EXPECT_EQ(L"4.2", format(L"{}", 4.2));
EXPECT_EQ(L"abc", format(L"{}", L"abc"));
EXPECT_EQ(L"z", format(L"{}", L'z'));
- EXPECT_THROW(fmt::format(L"{:*\x343E}", 42), fmt::format_error);
+ EXPECT_THROW(fmt::format(L"{:*\x343E}", 42), fmt::format_error);
}
TEST(FormatterTest, FormatStringFromSpeedTest) {
@@ -1659,7 +1659,7 @@ TEST(FormatTest, Print) {
"Don't panic!");
#endif
// Check that the wide print overload compiles.
- if (fmt::detail::const_check(false)) fmt::print(L"test");
+ if (fmt::detail::const_check(false)) fmt::print(L"test");
}
TEST(FormatTest, Variadic) {
@@ -1670,9 +1670,9 @@ TEST(FormatTest, Variadic) {
TEST(FormatTest, Dynamic) {
typedef fmt::format_context ctx;
std::vector<fmt::basic_format_arg<ctx>> args;
- args.emplace_back(fmt::detail::make_arg<ctx>(42));
- args.emplace_back(fmt::detail::make_arg<ctx>("abc1"));
- args.emplace_back(fmt::detail::make_arg<ctx>(1.5f));
+ args.emplace_back(fmt::detail::make_arg<ctx>(42));
+ args.emplace_back(fmt::detail::make_arg<ctx>("abc1"));
+ args.emplace_back(fmt::detail::make_arg<ctx>(1.5f));
std::string result = fmt::vformat(
"{} and {} and {}",
@@ -1873,7 +1873,7 @@ TEST(FormatTest, DynamicFormatter) {
"cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{:{0}}", num), format_error,
"cannot switch from automatic to manual argument indexing");
-#if FMT_DEPRECATED_NUMERIC_ALIGN
+#if FMT_DEPRECATED_NUMERIC_ALIGN
EXPECT_THROW_MSG(format("{:=}", str), format_error,
"format specifier requires numeric argument");
#endif
@@ -1891,30 +1891,30 @@ TEST(FormatTest, DynamicFormatter) {
"precision not allowed for this argument type");
}
-namespace adl_test {
-namespace fmt {
-namespace detail {
-struct foo {};
-template <typename, typename OutputIt> void write(OutputIt, foo) = delete;
-} // namespace detail
-} // namespace fmt
-} // namespace adl_test
-
-FMT_BEGIN_NAMESPACE
-template <>
-struct formatter<adl_test::fmt::detail::foo> : formatter<std::string> {
- template <typename FormatContext>
- auto format(adl_test::fmt::detail::foo, FormatContext& ctx)
- -> decltype(ctx.out()) {
- return formatter<std::string>::format("foo", ctx);
- }
-};
-FMT_END_NAMESPACE
-
+namespace adl_test {
+namespace fmt {
+namespace detail {
+struct foo {};
+template <typename, typename OutputIt> void write(OutputIt, foo) = delete;
+} // namespace detail
+} // namespace fmt
+} // namespace adl_test
+
+FMT_BEGIN_NAMESPACE
+template <>
+struct formatter<adl_test::fmt::detail::foo> : formatter<std::string> {
+ template <typename FormatContext>
+ auto format(adl_test::fmt::detail::foo, FormatContext& ctx)
+ -> decltype(ctx.out()) {
+ return formatter<std::string>::format("foo", ctx);
+ }
+};
+FMT_END_NAMESPACE
+
TEST(FormatTest, ToString) {
EXPECT_EQ("42", fmt::to_string(42));
EXPECT_EQ("0x1234", fmt::to_string(reinterpret_cast<void*>(0x1234)));
- EXPECT_EQ("foo", fmt::to_string(adl_test::fmt::detail::foo()));
+ EXPECT_EQ("foo", fmt::to_string(adl_test::fmt::detail::foo()));
}
TEST(FormatTest, ToWString) { EXPECT_EQ(L"42", fmt::to_wstring(42)); }
@@ -1932,12 +1932,12 @@ TEST(FormatTest, FormattedSize) {
EXPECT_EQ(2u, fmt::formatted_size("{}", 42));
}
-TEST(FormatTest, FormatTo) {
- std::vector<char> v;
- fmt::format_to(std::back_inserter(v), "{}", "foo");
- EXPECT_EQ(string_view(v.data(), v.size()), "foo");
-}
-
+TEST(FormatTest, FormatTo) {
+ std::vector<char> v;
+ fmt::format_to(std::back_inserter(v), "{}", "foo");
+ EXPECT_EQ(string_view(v.data(), v.size()), "foo");
+}
+
TEST(FormatTest, FormatToN) {
char buffer[4];
buffer[3] = 'x';
@@ -1945,12 +1945,12 @@ TEST(FormatTest, FormatToN) {
EXPECT_EQ(5u, result.size);
EXPECT_EQ(buffer + 3, result.out);
EXPECT_EQ("123x", fmt::string_view(buffer, 4));
-
+
result = fmt::format_to_n(buffer, 3, "{:s}", "foobar");
EXPECT_EQ(6u, result.size);
EXPECT_EQ(buffer + 3, result.out);
EXPECT_EQ("foox", fmt::string_view(buffer, 4));
-
+
buffer[0] = 'x';
buffer[1] = 'x';
buffer[2] = 'x';
@@ -1958,20 +1958,20 @@ TEST(FormatTest, FormatToN) {
EXPECT_EQ(1u, result.size);
EXPECT_EQ(buffer + 1, result.out);
EXPECT_EQ("Axxx", fmt::string_view(buffer, 4));
-
+
result = fmt::format_to_n(buffer, 3, "{}{} ", 'B', 'C');
EXPECT_EQ(3u, result.size);
EXPECT_EQ(buffer + 3, result.out);
EXPECT_EQ("BC x", fmt::string_view(buffer, 4));
-
- result = fmt::format_to_n(buffer, 4, "{}", "ABCDE");
- EXPECT_EQ(5u, result.size);
- EXPECT_EQ("ABCD", fmt::string_view(buffer, 4));
-
- buffer[3] = 'x';
- result = fmt::format_to_n(buffer, 3, "{}", std::string(1000, '*'));
- EXPECT_EQ(1000u, result.size);
- EXPECT_EQ("***x", fmt::string_view(buffer, 4));
+
+ result = fmt::format_to_n(buffer, 4, "{}", "ABCDE");
+ EXPECT_EQ(5u, result.size);
+ EXPECT_EQ("ABCD", fmt::string_view(buffer, 4));
+
+ buffer[3] = 'x';
+ result = fmt::format_to_n(buffer, 3, "{}", std::string(1000, '*'));
+ EXPECT_EQ(1000u, result.size);
+ EXPECT_EQ("***x", fmt::string_view(buffer, 4));
}
TEST(FormatTest, WideFormatToN) {
@@ -2046,7 +2046,7 @@ struct test_arg_id_handler {
template <size_t N>
FMT_CONSTEXPR test_arg_id_handler parse_arg_id(const char (&s)[N]) {
test_arg_id_handler h;
- fmt::detail::parse_arg_id(s, s + N, h);
+ fmt::detail::parse_arg_id(s, s + N, h);
return h;
}
@@ -2067,9 +2067,9 @@ struct test_format_specs_handler {
fmt::align_t align = fmt::align::none;
char fill = 0;
int width = 0;
- fmt::detail::arg_ref<char> width_ref;
+ fmt::detail::arg_ref<char> width_ref;
int precision = 0;
- fmt::detail::arg_ref<char> precision_ref;
+ fmt::detail::arg_ref<char> precision_ref;
char type = 0;
// Workaround for MSVC2017 bug that results in "expression did not evaluate
@@ -2095,12 +2095,12 @@ struct test_format_specs_handler {
FMT_CONSTEXPR void on_zero() { res = ZERO; }
FMT_CONSTEXPR void on_width(int w) { width = w; }
- FMT_CONSTEXPR void on_dynamic_width(fmt::detail::auto_id) {}
+ FMT_CONSTEXPR void on_dynamic_width(fmt::detail::auto_id) {}
FMT_CONSTEXPR void on_dynamic_width(int index) { width_ref = index; }
FMT_CONSTEXPR void on_dynamic_width(string_view) {}
FMT_CONSTEXPR void on_precision(int p) { precision = p; }
- FMT_CONSTEXPR void on_dynamic_precision(fmt::detail::auto_id) {}
+ FMT_CONSTEXPR void on_dynamic_precision(fmt::detail::auto_id) {}
FMT_CONSTEXPR void on_dynamic_precision(int index) { precision_ref = index; }
FMT_CONSTEXPR void on_dynamic_precision(string_view) {}
@@ -2112,7 +2112,7 @@ struct test_format_specs_handler {
template <size_t N>
FMT_CONSTEXPR test_format_specs_handler parse_test_specs(const char (&s)[N]) {
test_format_specs_handler h;
- fmt::detail::parse_format_specs(s, s + N, h);
+ fmt::detail::parse_format_specs(s, s + N, h);
return h;
}
@@ -2156,7 +2156,7 @@ struct test_context {
template <typename Id>
FMT_CONSTEXPR fmt::basic_format_arg<test_context> arg(Id id) {
- return fmt::detail::make_arg<test_context>(id);
+ return fmt::detail::make_arg<test_context>(id);
}
void on_error(const char*) {}
@@ -2169,7 +2169,7 @@ FMT_CONSTEXPR fmt::format_specs parse_specs(const char (&s)[N]) {
auto specs = fmt::format_specs();
auto parse_ctx = test_parse_context();
auto ctx = test_context();
- fmt::detail::specs_handler<test_parse_context, test_context> h(
+ fmt::detail::specs_handler<test_parse_context, test_context> h(
specs, parse_ctx, ctx);
parse_format_specs(s, s + N, h);
return specs;
@@ -2193,11 +2193,11 @@ TEST(FormatTest, ConstexprSpecsHandler) {
}
template <size_t N>
-FMT_CONSTEXPR fmt::detail::dynamic_format_specs<char> parse_dynamic_specs(
+FMT_CONSTEXPR fmt::detail::dynamic_format_specs<char> parse_dynamic_specs(
const char (&s)[N]) {
- fmt::detail::dynamic_format_specs<char> specs;
+ fmt::detail::dynamic_format_specs<char> specs;
test_parse_context ctx{};
- fmt::detail::dynamic_specs_handler<test_parse_context> h(specs, ctx);
+ fmt::detail::dynamic_specs_handler<test_parse_context> h(specs, ctx);
parse_format_specs(s, s + N, h);
return specs;
}
@@ -2221,8 +2221,8 @@ TEST(FormatTest, ConstexprDynamicSpecsHandler) {
template <size_t N>
FMT_CONSTEXPR test_format_specs_handler check_specs(const char (&s)[N]) {
- fmt::detail::specs_checker<test_format_specs_handler> checker(
- test_format_specs_handler(), fmt::detail::type::double_type);
+ fmt::detail::specs_checker<test_format_specs_handler> checker(
+ test_format_specs_handler(), fmt::detail::type::double_type);
parse_format_specs(s, s + N, checker);
return checker;
}
@@ -2247,14 +2247,14 @@ TEST(FormatTest, ConstexprSpecsChecker) {
struct test_format_string_handler {
FMT_CONSTEXPR void on_text(const char*, const char*) {}
- FMT_CONSTEXPR int on_arg_id() { return 0; }
+ FMT_CONSTEXPR int on_arg_id() { return 0; }
- template <typename T> FMT_CONSTEXPR int on_arg_id(T) { return 0; }
+ template <typename T> FMT_CONSTEXPR int on_arg_id(T) { return 0; }
- FMT_CONSTEXPR void on_replacement_field(int, const char*) {}
+ FMT_CONSTEXPR void on_replacement_field(int, const char*) {}
- FMT_CONSTEXPR const char* on_format_specs(int, const char* begin,
- const char*) {
+ FMT_CONSTEXPR const char* on_format_specs(int, const char* begin,
+ const char*) {
return begin;
}
@@ -2265,7 +2265,7 @@ struct test_format_string_handler {
template <size_t N> FMT_CONSTEXPR bool parse_string(const char (&s)[N]) {
test_format_string_handler h;
- fmt::detail::parse_format_string<true>(fmt::string_view(s, N - 1), h);
+ fmt::detail::parse_format_string<true>(fmt::string_view(s, N - 1), h);
return !h.error;
}
@@ -2309,10 +2309,10 @@ FMT_CONSTEXPR bool equal(const char* s1, const char* s2) {
template <typename... Args>
FMT_CONSTEXPR bool test_error(const char* fmt, const char* expected_error) {
const char* actual_error = nullptr;
- string_view s(fmt, len(fmt));
- fmt::detail::format_string_checker<char, test_error_handler, Args...> checker(
- s, test_error_handler(actual_error));
- fmt::detail::parse_format_string<true>(s, checker);
+ string_view s(fmt, len(fmt));
+ fmt::detail::format_string_checker<char, test_error_handler, Args...> checker(
+ s, test_error_handler(actual_error));
+ fmt::detail::parse_format_string<true>(s, checker);
return equal(actual_error, expected_error);
}
@@ -2325,13 +2325,13 @@ TEST(FormatTest, FormatStringErrors) {
EXPECT_ERROR_NOARGS("foo", nullptr);
EXPECT_ERROR_NOARGS("}", "unmatched '}' in format string");
EXPECT_ERROR("{0:s", "unknown format specifier", Date);
-# if !FMT_MSC_VER || FMT_MSC_VER >= 1916
- // This causes an detail compiler error in MSVC2017.
+# if !FMT_MSC_VER || FMT_MSC_VER >= 1916
+ // This causes an detail compiler error in MSVC2017.
EXPECT_ERROR("{:{<}", "invalid fill character '{'", int);
EXPECT_ERROR("{:10000000000}", "number is too big", int);
EXPECT_ERROR("{:.10000000000}", "number is too big", int);
- EXPECT_ERROR_NOARGS("{:x}", "argument not found");
-# if FMT_DEPRECATED_NUMERIC_ALIGN
+ EXPECT_ERROR_NOARGS("{:x}", "argument not found");
+# if FMT_DEPRECATED_NUMERIC_ALIGN
EXPECT_ERROR("{0:=5", "unknown format specifier", int);
EXPECT_ERROR("{:=}", "format specifier requires numeric argument",
const char*);
@@ -2349,8 +2349,8 @@ TEST(FormatTest, FormatStringErrors) {
EXPECT_ERROR("{:+}", "format specifier requires signed argument", unsigned);
EXPECT_ERROR("{:-}", "format specifier requires signed argument", unsigned);
EXPECT_ERROR("{: }", "format specifier requires signed argument", unsigned);
- EXPECT_ERROR("{:{}}", "argument not found", int);
- EXPECT_ERROR("{:.{}}", "argument not found", double);
+ EXPECT_ERROR("{:{}}", "argument not found", int);
+ EXPECT_ERROR("{:.{}}", "argument not found", double);
EXPECT_ERROR("{:.2}", "precision not allowed for this argument type", int);
EXPECT_ERROR("{:s}", "invalid type specifier", int);
EXPECT_ERROR("{:s}", "invalid type specifier", bool);
@@ -2373,8 +2373,8 @@ TEST(FormatTest, FormatStringErrors) {
EXPECT_ERROR("{:.{0x}}", "invalid format string", int);
EXPECT_ERROR("{:.{-}}", "invalid format string", int);
EXPECT_ERROR("{:.x}", "missing precision specifier", int);
- EXPECT_ERROR_NOARGS("{}", "argument not found");
- EXPECT_ERROR("{1}", "argument not found", int);
+ EXPECT_ERROR_NOARGS("{}", "argument not found");
+ EXPECT_ERROR("{1}", "argument not found", int);
EXPECT_ERROR("{1}{}",
"cannot switch from manual to automatic argument indexing", int,
int);
@@ -2385,7 +2385,7 @@ TEST(FormatTest, FormatStringErrors) {
TEST(FormatTest, VFormatTo) {
typedef fmt::format_context context;
- fmt::basic_format_arg<context> arg = fmt::detail::make_arg<context>(42);
+ fmt::basic_format_arg<context> arg = fmt::detail::make_arg<context>(42);
fmt::basic_format_args<context> args(&arg, 1);
std::string s;
fmt::vformat_to(std::back_inserter(s), "{}", args);
@@ -2395,7 +2395,7 @@ TEST(FormatTest, VFormatTo) {
EXPECT_EQ("42", s);
typedef fmt::wformat_context wcontext;
- fmt::basic_format_arg<wcontext> warg = fmt::detail::make_arg<wcontext>(42);
+ fmt::basic_format_arg<wcontext> warg = fmt::detail::make_arg<wcontext>(42);
fmt::basic_format_args<wcontext> wargs(&warg, 1);
std::wstring w;
fmt::vformat_to(std::back_inserter(w), L"{}", wargs);
@@ -2417,7 +2417,7 @@ TEST(FormatTest, FmtStringInTemplate) {
#endif // FMT_USE_CONSTEXPR
TEST(FormatTest, CharTraitsIsNotAmbiguous) {
- // Test that we don't inject detail names into the std namespace.
+ // Test that we don't inject detail names into the std namespace.
using namespace std;
char_traits<char>::char_type c;
(void)c;
@@ -2428,30 +2428,30 @@ TEST(FormatTest, CharTraitsIsNotAmbiguous) {
#endif
}
-#if __cplusplus > 201103L
-struct custom_char {
+#if __cplusplus > 201103L
+struct custom_char {
int value;
- custom_char() = default;
+ custom_char() = default;
- template <typename T>
- constexpr custom_char(T val) : value(static_cast<int>(val)) {}
+ template <typename T>
+ constexpr custom_char(T val) : value(static_cast<int>(val)) {}
operator int() const { return value; }
};
-int to_ascii(custom_char c) { return c; }
-
+int to_ascii(custom_char c) { return c; }
+
FMT_BEGIN_NAMESPACE
-template <> struct is_char<custom_char> : std::true_type {};
+template <> struct is_char<custom_char> : std::true_type {};
FMT_END_NAMESPACE
TEST(FormatTest, FormatCustomChar) {
- const custom_char format[] = {'{', '}', 0};
- auto result = fmt::format(format, custom_char('x'));
+ const custom_char format[] = {'{', '}', 0};
+ auto result = fmt::format(format, custom_char('x'));
EXPECT_EQ(result.size(), 1);
- EXPECT_EQ(result[0], custom_char('x'));
+ EXPECT_EQ(result[0], custom_char('x'));
}
-#endif
+#endif
// Convert a char8_t string to std::string. Otherwise GTest will insist on
// inserting `char8_t` NTBS into a `char` stream which is disabled by P1423.
@@ -2460,36 +2460,36 @@ template <typename S> std::string from_u8str(const S& str) {
}
TEST(FormatTest, FormatUTF8Precision) {
- using str_type = std::basic_string<fmt::detail::char8_type>;
- str_type format(reinterpret_cast<const fmt::detail::char8_type*>(u8"{:.4}"));
- str_type str(reinterpret_cast<const fmt::detail::char8_type*>(
+ using str_type = std::basic_string<fmt::detail::char8_type>;
+ str_type format(reinterpret_cast<const fmt::detail::char8_type*>(u8"{:.4}"));
+ str_type str(reinterpret_cast<const fmt::detail::char8_type*>(
u8"caf\u00e9s")); // cafés
auto result = fmt::format(format, str);
- EXPECT_EQ(fmt::detail::count_code_points(result), 4);
+ EXPECT_EQ(fmt::detail::count_code_points(result), 4);
EXPECT_EQ(result.size(), 5);
EXPECT_EQ(from_u8str(result), from_u8str(str.substr(0, 5)));
}
-
-struct check_back_appender {};
-
-FMT_BEGIN_NAMESPACE
-template <> struct formatter<check_back_appender> {
- template <typename ParseContext>
- auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
- return ctx.begin();
- }
-
- template <typename Context>
- auto format(check_back_appender, Context& ctx) -> decltype(ctx.out()) {
- auto out = ctx.out();
- static_assert(std::is_same<decltype(++out), decltype(out)&>::value,
- "needs to satisfy weakly_incrementable");
- *out = 'y';
- return ++out;
- }
-};
-FMT_END_NAMESPACE
-
-TEST(FormatTest, BackInsertSlicing) {
- EXPECT_EQ(fmt::format("{}", check_back_appender{}), "y");
-}
+
+struct check_back_appender {};
+
+FMT_BEGIN_NAMESPACE
+template <> struct formatter<check_back_appender> {
+ template <typename ParseContext>
+ auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
+ return ctx.begin();
+ }
+
+ template <typename Context>
+ auto format(check_back_appender, Context& ctx) -> decltype(ctx.out()) {
+ auto out = ctx.out();
+ static_assert(std::is_same<decltype(++out), decltype(out)&>::value,
+ "needs to satisfy weakly_incrementable");
+ *out = 'y';
+ return ++out;
+ }
+};
+FMT_END_NAMESPACE
+
+TEST(FormatTest, BackInsertSlicing) {
+ EXPECT_EQ(fmt::format("{}", check_back_appender{}), "y");
+}
diff --git a/contrib/libs/fmt/test/format-test/ya.make b/contrib/libs/fmt/test/format-test/ya.make
index 67fd53ced8..bc3d7c85c8 100644
--- a/contrib/libs/fmt/test/format-test/ya.make
+++ b/contrib/libs/fmt/test/format-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
ALLOCATOR(J)
diff --git a/contrib/libs/fmt/test/gtest-extra-test.cc b/contrib/libs/fmt/test/gtest-extra-test.cc
index 2374197a93..ea728607e8 100644
--- a/contrib/libs/fmt/test/gtest-extra-test.cc
+++ b/contrib/libs/fmt/test/gtest-extra-test.cc
@@ -8,7 +8,7 @@
#include "gtest-extra.h"
#include <gtest/gtest-spi.h>
-
+
#include <algorithm>
#include <cstring>
#include <memory>
@@ -168,24 +168,24 @@ TEST_F(SingleEvaluationTest, FailedEXPECT_WRITE) {
// Tests that assertion arguments are evaluated exactly once.
TEST_F(SingleEvaluationTest, WriteTests) {
// successful EXPECT_WRITE
- EXPECT_WRITE(
- stdout,
- { // NOLINT
- a_++;
- std::printf("test");
- },
- (b_++, "test"));
+ EXPECT_WRITE(
+ stdout,
+ { // NOLINT
+ a_++;
+ std::printf("test");
+ },
+ (b_++, "test"));
EXPECT_EQ(1, a_);
EXPECT_EQ(1, b_);
// failed EXPECT_WRITE
- EXPECT_NONFATAL_FAILURE(EXPECT_WRITE(
- stdout,
- { // NOLINT
- a_++;
- std::printf("test");
- },
- (b_++, "other")),
+ EXPECT_NONFATAL_FAILURE(EXPECT_WRITE(
+ stdout,
+ { // NOLINT
+ a_++;
+ std::printf("test");
+ },
+ (b_++, "other")),
"Actual: test");
EXPECT_EQ(2, a_);
EXPECT_EQ(2, b_);
@@ -420,17 +420,17 @@ TEST(OutputRedirectTest, ErrorInDtor) {
std::unique_ptr<OutputRedirect> redir(new OutputRedirect(f.get()));
// Put a character in a file buffer.
EXPECT_EQ('x', fputc('x', f.get()));
- EXPECT_WRITE(
- stderr,
- {
- // The close function must be called inside EXPECT_WRITE,
- // otherwise the system may recycle closed file descriptor when
- // redirecting the output in EXPECT_STDERR and the second close
- // will break output redirection.
- FMT_POSIX(close(write_fd));
- SUPPRESS_ASSERT(redir.reset(nullptr));
- },
- format_system_error(EBADF, "cannot flush stream"));
+ EXPECT_WRITE(
+ stderr,
+ {
+ // The close function must be called inside EXPECT_WRITE,
+ // otherwise the system may recycle closed file descriptor when
+ // redirecting the output in EXPECT_STDERR and the second close
+ // will break output redirection.
+ FMT_POSIX(close(write_fd));
+ SUPPRESS_ASSERT(redir.reset(nullptr));
+ },
+ format_system_error(EBADF, "cannot flush stream"));
write_copy.dup2(write_fd); // "undo" close or dtor of buffered_file will fail
}
diff --git a/contrib/libs/fmt/test/gtest-extra-test/ya.make b/contrib/libs/fmt/test/gtest-extra-test/ya.make
index 060b7086b5..b8d6cf8316 100644
--- a/contrib/libs/fmt/test/gtest-extra-test/ya.make
+++ b/contrib/libs/fmt/test/gtest-extra-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/gtest-extra.cc b/contrib/libs/fmt/test/gtest-extra.cc
index 0128ab3103..58628a8a98 100644
--- a/contrib/libs/fmt/test/gtest-extra.cc
+++ b/contrib/libs/fmt/test/gtest-extra.cc
@@ -57,7 +57,7 @@ std::string OutputRedirect::restore_and_read() {
if (read_end_.descriptor() == -1) return content; // Already read.
enum { BUFFER_SIZE = 4096 };
char buffer[BUFFER_SIZE];
- size_t count = 0;
+ size_t count = 0;
do {
count = read_end_.read(buffer, BUFFER_SIZE);
content.append(buffer, count);
@@ -66,9 +66,9 @@ std::string OutputRedirect::restore_and_read() {
return content;
}
-std::string read(file& f, size_t count) {
+std::string read(file& f, size_t count) {
std::string buffer(count, '\0');
- size_t n = 0, offset = 0;
+ size_t n = 0, offset = 0;
do {
n = f.read(&buffer[offset], count - offset);
// We can't read more than size_t bytes since count has type size_t.
diff --git a/contrib/libs/fmt/test/gtest-extra.h b/contrib/libs/fmt/test/gtest-extra.h
index 5f392d9019..36be158bbb 100644
--- a/contrib/libs/fmt/test/gtest-extra.h
+++ b/contrib/libs/fmt/test/gtest-extra.h
@@ -9,8 +9,8 @@
#define FMT_GTEST_EXTRA_H_
#include <string>
-
-#include "fmt/os.h"
+
+#include "fmt/os.h"
#include <gmock/gmock.h>
#define FMT_TEST_THROW_(statement, expected_exception, expected_message, fail) \
@@ -139,20 +139,20 @@ class SuppressAssert {
EXPECT_SYSTEM_ERROR(SUPPRESS_ASSERT(statement), error_code, message)
// Attempts to read count characters from a file.
-std::string read(fmt::file& f, size_t count);
+std::string read(fmt::file& f, size_t count);
# define EXPECT_READ(file, expected_content) \
- EXPECT_EQ(expected_content, \
- read(file, fmt::string_view(expected_content).size()))
+ EXPECT_EQ(expected_content, \
+ read(file, fmt::string_view(expected_content).size()))
#else
-# define EXPECT_WRITE(file, statement, expected_output) \
- do { \
- (void)(file); \
- (void)(statement); \
- (void)(expected_output); \
- SUCCEED(); \
- } while (false)
+# define EXPECT_WRITE(file, statement, expected_output) \
+ do { \
+ (void)(file); \
+ (void)(statement); \
+ (void)(expected_output); \
+ SUCCEED(); \
+ } while (false)
#endif // FMT_USE_FCNTL
template <typename Mock> struct ScopedMock : testing::StrictMock<Mock> {
diff --git a/contrib/libs/fmt/test/header-only-test/ya.make b/contrib/libs/fmt/test/header-only-test/ya.make
index ce7b392e59..cfbc290203 100644
--- a/contrib/libs/fmt/test/header-only-test/ya.make
+++ b/contrib/libs/fmt/test/header-only-test/ya.make
@@ -1,18 +1,18 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
- contrib/libs/fmt
+ contrib/libs/fmt
contrib/libs/fmt/test
)
diff --git a/contrib/libs/fmt/test/locale-test.cc b/contrib/libs/fmt/test/locale-test.cc
index 9e0eb2b128..7d776b4290 100644
--- a/contrib/libs/fmt/test/locale-test.cc
+++ b/contrib/libs/fmt/test/locale-test.cc
@@ -6,12 +6,12 @@
// For the license information refer to format.h.
#include "fmt/locale.h"
-
-#include <complex>
-
+
+#include <complex>
+
#include <gmock/gmock.h>
-using fmt::detail::max_value;
+using fmt::detail::max_value;
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
template <typename Char> struct numpunct : std::numpunct<Char> {
@@ -44,117 +44,117 @@ template <typename Char> struct small_grouping : std::numpunct<Char> {
TEST(LocaleTest, DoubleDecimalPoint) {
std::locale loc(std::locale(), new numpunct<char>());
- EXPECT_EQ("1?23", fmt::format(loc, "{:L}", 1.23));
+ EXPECT_EQ("1?23", fmt::format(loc, "{:L}", 1.23));
}
TEST(LocaleTest, Format) {
std::locale loc(std::locale(), new numpunct<char>());
- EXPECT_EQ("1234567", fmt::format(std::locale(), "{:L}", 1234567));
- EXPECT_EQ("1~234~567", fmt::format(loc, "{:L}", 1234567));
- EXPECT_EQ("-1~234~567", fmt::format(loc, "{:L}", -1234567));
- EXPECT_EQ("-256", fmt::format(loc, "{:L}", -256));
+ EXPECT_EQ("1234567", fmt::format(std::locale(), "{:L}", 1234567));
+ EXPECT_EQ("1~234~567", fmt::format(loc, "{:L}", 1234567));
+ EXPECT_EQ("-1~234~567", fmt::format(loc, "{:L}", -1234567));
+ EXPECT_EQ("-256", fmt::format(loc, "{:L}", -256));
fmt::format_arg_store<fmt::format_context, int> as{1234567};
- EXPECT_EQ("1~234~567", fmt::vformat(loc, "{:L}", fmt::format_args(as)));
+ EXPECT_EQ("1~234~567", fmt::vformat(loc, "{:L}", fmt::format_args(as)));
std::string s;
- fmt::format_to(std::back_inserter(s), loc, "{:L}", 1234567);
+ fmt::format_to(std::back_inserter(s), loc, "{:L}", 1234567);
EXPECT_EQ("1~234~567", s);
std::locale no_grouping_loc(std::locale(), new no_grouping<char>());
- EXPECT_EQ("1234567", fmt::format(no_grouping_loc, "{:L}", 1234567));
+ EXPECT_EQ("1234567", fmt::format(no_grouping_loc, "{:L}", 1234567));
std::locale special_grouping_loc(std::locale(), new special_grouping<char>());
- EXPECT_EQ("1,23,45,678", fmt::format(special_grouping_loc, "{:L}", 12345678));
- EXPECT_EQ("12,345", fmt::format(special_grouping_loc, "{:L}", 12345));
+ EXPECT_EQ("1,23,45,678", fmt::format(special_grouping_loc, "{:L}", 12345678));
+ EXPECT_EQ("12,345", fmt::format(special_grouping_loc, "{:L}", 12345));
std::locale small_grouping_loc(std::locale(), new small_grouping<char>());
EXPECT_EQ("4,2,9,4,9,6,7,2,9,5",
- fmt::format(small_grouping_loc, "{:L}", max_value<uint32_t>()));
+ fmt::format(small_grouping_loc, "{:L}", max_value<uint32_t>()));
+}
+
+TEST(LocaleTest, FormatDetaultAlign) {
+ std::locale special_grouping_loc(std::locale(), new special_grouping<char>());
+ EXPECT_EQ(" 12,345", fmt::format(special_grouping_loc, "{:8L}", 12345));
}
-TEST(LocaleTest, FormatDetaultAlign) {
- std::locale special_grouping_loc(std::locale(), new special_grouping<char>());
- EXPECT_EQ(" 12,345", fmt::format(special_grouping_loc, "{:8L}", 12345));
-}
-
TEST(LocaleTest, WFormat) {
std::locale loc(std::locale(), new numpunct<wchar_t>());
- EXPECT_EQ(L"1234567", fmt::format(std::locale(), L"{:L}", 1234567));
- EXPECT_EQ(L"1~234~567", fmt::format(loc, L"{:L}", 1234567));
+ EXPECT_EQ(L"1234567", fmt::format(std::locale(), L"{:L}", 1234567));
+ EXPECT_EQ(L"1~234~567", fmt::format(loc, L"{:L}", 1234567));
fmt::format_arg_store<fmt::wformat_context, int> as{1234567};
- EXPECT_EQ(L"1~234~567", fmt::vformat(loc, L"{:L}", fmt::wformat_args(as)));
- EXPECT_EQ(L"1234567", fmt::format(std::locale("C"), L"{:L}", 1234567));
+ EXPECT_EQ(L"1~234~567", fmt::vformat(loc, L"{:L}", fmt::wformat_args(as)));
+ EXPECT_EQ(L"1234567", fmt::format(std::locale("C"), L"{:L}", 1234567));
std::locale no_grouping_loc(std::locale(), new no_grouping<wchar_t>());
- EXPECT_EQ(L"1234567", fmt::format(no_grouping_loc, L"{:L}", 1234567));
+ EXPECT_EQ(L"1234567", fmt::format(no_grouping_loc, L"{:L}", 1234567));
std::locale special_grouping_loc(std::locale(),
new special_grouping<wchar_t>());
EXPECT_EQ(L"1,23,45,678",
- fmt::format(special_grouping_loc, L"{:L}", 12345678));
+ fmt::format(special_grouping_loc, L"{:L}", 12345678));
std::locale small_grouping_loc(std::locale(), new small_grouping<wchar_t>());
EXPECT_EQ(L"4,2,9,4,9,6,7,2,9,5",
- fmt::format(small_grouping_loc, L"{:L}", max_value<uint32_t>()));
+ fmt::format(small_grouping_loc, L"{:L}", max_value<uint32_t>()));
+}
+
+TEST(LocaleTest, DoubleFormatter) {
+ auto loc = std::locale(std::locale(), new special_grouping<char>());
+ auto f = fmt::formatter<int>();
+ auto parse_ctx = fmt::format_parse_context("L");
+ f.parse(parse_ctx);
+ char buf[10] = {};
+ fmt::basic_format_context<char*, char> format_ctx(
+ buf, {}, fmt::detail::locale_ref(loc));
+ *f.format(12345, format_ctx) = 0;
+ EXPECT_STREQ("12,345", buf);
+}
+
+FMT_BEGIN_NAMESPACE
+template <class charT> struct formatter<std::complex<double>, charT> {
+ private:
+ detail::dynamic_format_specs<char> specs_;
+
+ public:
+ typename basic_format_parse_context<charT>::iterator parse(
+ basic_format_parse_context<charT>& ctx) {
+ using handler_type =
+ detail::dynamic_specs_handler<basic_format_parse_context<charT>>;
+ detail::specs_checker<handler_type> handler(handler_type(specs_, ctx),
+ detail::type::string_type);
+ auto it = parse_format_specs(ctx.begin(), ctx.end(), handler);
+ detail::parse_float_type_spec(specs_, ctx.error_handler());
+ return it;
+ }
+
+ template <class FormatContext>
+ typename FormatContext::iterator format(const std::complex<double>& c,
+ FormatContext& ctx) {
+ detail::handle_dynamic_spec<detail::precision_checker>(
+ specs_.precision, specs_.precision_ref, ctx);
+ auto format_specs = std::string();
+ if (specs_.precision > 0)
+ format_specs = fmt::format(".{}", specs_.precision);
+ if (specs_.type)
+ format_specs += specs_.type;
+ auto real = fmt::format(ctx.locale().template get<std::locale>(),
+ "{:" + format_specs + "}", c.real());
+ auto imag = fmt::format(ctx.locale().template get<std::locale>(),
+ "{:" + format_specs + "}", c.imag());
+ auto fill_align_width = std::string();
+ if (specs_.width > 0)
+ fill_align_width = fmt::format(">{}", specs_.width);
+ return format_to(
+ ctx.out(), "{:" + fill_align_width + "}",
+ fmt::format(c.real() != 0 ? "({0}+{1}i)" : "{1}i", real, imag));
+ }
+};
+FMT_END_NAMESPACE
+
+TEST(FormatTest, Complex) {
+ std::string s = fmt::format("{}", std::complex<double>(1, 2));
+ EXPECT_EQ(s, "(1+2i)");
+ EXPECT_EQ(fmt::format("{:.2f}", std::complex<double>(1, 2)), "(1.00+2.00i)");
+ EXPECT_EQ(fmt::format("{:8}", std::complex<double>(1, 2)), " (1+2i)");
}
-TEST(LocaleTest, DoubleFormatter) {
- auto loc = std::locale(std::locale(), new special_grouping<char>());
- auto f = fmt::formatter<int>();
- auto parse_ctx = fmt::format_parse_context("L");
- f.parse(parse_ctx);
- char buf[10] = {};
- fmt::basic_format_context<char*, char> format_ctx(
- buf, {}, fmt::detail::locale_ref(loc));
- *f.format(12345, format_ctx) = 0;
- EXPECT_STREQ("12,345", buf);
-}
-
-FMT_BEGIN_NAMESPACE
-template <class charT> struct formatter<std::complex<double>, charT> {
- private:
- detail::dynamic_format_specs<char> specs_;
-
- public:
- typename basic_format_parse_context<charT>::iterator parse(
- basic_format_parse_context<charT>& ctx) {
- using handler_type =
- detail::dynamic_specs_handler<basic_format_parse_context<charT>>;
- detail::specs_checker<handler_type> handler(handler_type(specs_, ctx),
- detail::type::string_type);
- auto it = parse_format_specs(ctx.begin(), ctx.end(), handler);
- detail::parse_float_type_spec(specs_, ctx.error_handler());
- return it;
- }
-
- template <class FormatContext>
- typename FormatContext::iterator format(const std::complex<double>& c,
- FormatContext& ctx) {
- detail::handle_dynamic_spec<detail::precision_checker>(
- specs_.precision, specs_.precision_ref, ctx);
- auto format_specs = std::string();
- if (specs_.precision > 0)
- format_specs = fmt::format(".{}", specs_.precision);
- if (specs_.type)
- format_specs += specs_.type;
- auto real = fmt::format(ctx.locale().template get<std::locale>(),
- "{:" + format_specs + "}", c.real());
- auto imag = fmt::format(ctx.locale().template get<std::locale>(),
- "{:" + format_specs + "}", c.imag());
- auto fill_align_width = std::string();
- if (specs_.width > 0)
- fill_align_width = fmt::format(">{}", specs_.width);
- return format_to(
- ctx.out(), "{:" + fill_align_width + "}",
- fmt::format(c.real() != 0 ? "({0}+{1}i)" : "{1}i", real, imag));
- }
-};
-FMT_END_NAMESPACE
-
-TEST(FormatTest, Complex) {
- std::string s = fmt::format("{}", std::complex<double>(1, 2));
- EXPECT_EQ(s, "(1+2i)");
- EXPECT_EQ(fmt::format("{:.2f}", std::complex<double>(1, 2)), "(1.00+2.00i)");
- EXPECT_EQ(fmt::format("{:8}", std::complex<double>(1, 2)), " (1+2i)");
-}
-
#endif // FMT_STATIC_THOUSANDS_SEPARATOR
diff --git a/contrib/libs/fmt/test/locale-test/ya.make b/contrib/libs/fmt/test/locale-test/ya.make
index 8295882dec..06a53a939c 100644
--- a/contrib/libs/fmt/test/locale-test/ya.make
+++ b/contrib/libs/fmt/test/locale-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/mock-allocator.h b/contrib/libs/fmt/test/mock-allocator.h
index c075cda254..dfc13feee7 100644
--- a/contrib/libs/fmt/test/mock-allocator.h
+++ b/contrib/libs/fmt/test/mock-allocator.h
@@ -16,8 +16,8 @@ template <typename T> class mock_allocator {
mock_allocator() {}
mock_allocator(const mock_allocator&) {}
typedef T value_type;
- MOCK_METHOD1_T(allocate, T*(size_t n));
- MOCK_METHOD2_T(deallocate, void(T* p, size_t n));
+ MOCK_METHOD1_T(allocate, T*(size_t n));
+ MOCK_METHOD2_T(deallocate, void(T* p, size_t n));
};
template <typename Allocator> class allocator_ref {
@@ -51,10 +51,10 @@ template <typename Allocator> class allocator_ref {
public:
Allocator* get() const { return alloc_; }
- value_type* allocate(size_t n) {
+ value_type* allocate(size_t n) {
return std::allocator_traits<Allocator>::allocate(*alloc_, n);
}
- void deallocate(value_type* p, size_t n) { alloc_->deallocate(p, n); }
+ void deallocate(value_type* p, size_t n) { alloc_->deallocate(p, n); }
};
#endif // FMT_MOCK_ALLOCATOR_H_
diff --git a/contrib/libs/fmt/test/os-test.cc b/contrib/libs/fmt/test/os-test.cc
index 52226db568..359b5ff8ce 100644
--- a/contrib/libs/fmt/test/os-test.cc
+++ b/contrib/libs/fmt/test/os-test.cc
@@ -5,8 +5,8 @@
//
// For the license information refer to format.h.
-#include "fmt/os.h"
-
+#include "fmt/os.h"
+
#include <cstdlib> // std::exit
#include <cstring>
#include <memory>
@@ -27,14 +27,14 @@ using fmt::error_code;
TEST(UtilTest, UTF16ToUTF8) {
std::string s = "ёжик";
- fmt::detail::utf16_to_utf8 u(L"\x0451\x0436\x0438\x043A");
+ fmt::detail::utf16_to_utf8 u(L"\x0451\x0436\x0438\x043A");
EXPECT_EQ(s, u.str());
EXPECT_EQ(s.size(), u.size());
}
TEST(UtilTest, UTF16ToUTF8EmptyString) {
std::string s = "";
- fmt::detail::utf16_to_utf8 u(L"");
+ fmt::detail::utf16_to_utf8 u(L"");
EXPECT_EQ(s, u.str());
EXPECT_EQ(s.size(), u.size());
}
@@ -44,7 +44,7 @@ void check_utf_conversion_error(
const char* message,
fmt::basic_string_view<Char> str = fmt::basic_string_view<Char>(0, 1)) {
fmt::memory_buffer out;
- fmt::detail::format_windows_error(out, ERROR_INVALID_PARAMETER, message);
+ fmt::detail::format_windows_error(out, ERROR_INVALID_PARAMETER, message);
fmt::system_error error(0, "");
try {
(Converter)(str);
@@ -56,12 +56,12 @@ void check_utf_conversion_error(
}
TEST(UtilTest, UTF16ToUTF8Error) {
- check_utf_conversion_error<fmt::detail::utf16_to_utf8, wchar_t>(
+ check_utf_conversion_error<fmt::detail::utf16_to_utf8, wchar_t>(
"cannot convert string from UTF-16 to UTF-8");
}
TEST(UtilTest, UTF16ToUTF8Convert) {
- fmt::detail::utf16_to_utf8 u;
+ fmt::detail::utf16_to_utf8 u;
EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(fmt::wstring_view(0, 1)));
EXPECT_EQ(ERROR_INVALID_PARAMETER,
u.convert(fmt::wstring_view(L"foo", INT_MAX + 1u)));
@@ -74,16 +74,16 @@ TEST(UtilTest, FormatWindowsError) {
0, ERROR_FILE_EXISTS,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPWSTR>(&message), 0, 0);
- fmt::detail::utf16_to_utf8 utf8_message(message);
+ fmt::detail::utf16_to_utf8 utf8_message(message);
LocalFree(message);
fmt::memory_buffer actual_message;
- fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, "test");
+ fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, "test");
EXPECT_EQ(fmt::format("test: {}", utf8_message.str()),
fmt::to_string(actual_message));
actual_message.resize(0);
- auto max_size = fmt::detail::max_value<size_t>() / 2;
- fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS,
- fmt::string_view(nullptr, max_size));
+ auto max_size = fmt::detail::max_value<size_t>() / 2;
+ fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS,
+ fmt::string_view(nullptr, max_size));
EXPECT_EQ(fmt::format("error {}", ERROR_FILE_EXISTS),
fmt::to_string(actual_message));
}
@@ -103,11 +103,11 @@ TEST(UtilTest, FormatLongWindowsError) {
reinterpret_cast<LPWSTR>(&message), 0, 0) == 0) {
return;
}
- fmt::detail::utf16_to_utf8 utf8_message(message);
+ fmt::detail::utf16_to_utf8 utf8_message(message);
LocalFree(message);
fmt::memory_buffer actual_message;
- fmt::detail::format_windows_error(actual_message, provisioning_not_allowed,
- "test");
+ fmt::detail::format_windows_error(actual_message, provisioning_not_allowed,
+ "test");
EXPECT_EQ(fmt::format("test: {}", utf8_message.str()),
fmt::to_string(actual_message));
}
@@ -120,14 +120,14 @@ TEST(UtilTest, WindowsError) {
error = e;
}
fmt::memory_buffer message;
- fmt::detail::format_windows_error(message, ERROR_FILE_EXISTS, "test error");
+ fmt::detail::format_windows_error(message, ERROR_FILE_EXISTS, "test error");
EXPECT_EQ(to_string(message), error.what());
EXPECT_EQ(ERROR_FILE_EXISTS, error.error_code());
}
TEST(UtilTest, ReportWindowsError) {
fmt::memory_buffer out;
- fmt::detail::format_windows_error(out, ERROR_FILE_EXISTS, "test error");
+ fmt::detail::format_windows_error(out, ERROR_FILE_EXISTS, "test error");
out.push_back('\n');
EXPECT_WRITE(stderr,
fmt::report_windows_error(ERROR_FILE_EXISTS, "test error"),
@@ -164,10 +164,10 @@ static file open_file() {
// Attempts to write a string to a file.
static void write(file& f, fmt::string_view s) {
- size_t num_chars_left = s.size();
+ size_t num_chars_left = s.size();
const char* ptr = s.data();
do {
- size_t count = f.write(ptr, num_chars_left);
+ size_t count = f.write(ptr, num_chars_left);
ptr += count;
// We can't write more than size_t bytes since num_chars_left
// has type size_t.
@@ -238,17 +238,17 @@ TEST(BufferedFileTest, CloseFileInDtor) {
TEST(BufferedFileTest, CloseErrorInDtor) {
std::unique_ptr<buffered_file> f(new buffered_file(open_buffered_file()));
- EXPECT_WRITE(
- stderr,
- {
- // The close function must be called inside EXPECT_WRITE,
- // otherwise the system may recycle closed file descriptor when
- // redirecting the output in EXPECT_STDERR and the second close
- // will break output redirection.
- FMT_POSIX(close(f->fileno()));
- SUPPRESS_ASSERT(f.reset(nullptr));
- },
- format_system_error(EBADF, "cannot close file") + "\n");
+ EXPECT_WRITE(
+ stderr,
+ {
+ // The close function must be called inside EXPECT_WRITE,
+ // otherwise the system may recycle closed file descriptor when
+ // redirecting the output in EXPECT_STDERR and the second close
+ // will break output redirection.
+ FMT_POSIX(close(f->fileno()));
+ SUPPRESS_ASSERT(f.reset(nullptr));
+ },
+ format_system_error(EBADF, "cannot close file") + "\n");
}
TEST(BufferedFileTest, Close) {
@@ -287,38 +287,38 @@ TEST(BufferedFileTest, Fileno) {
EXPECT_READ(copy, FILE_CONTENT);
}
-TEST(OStreamTest, Move) {
- fmt::ostream out = fmt::output_file("test-file");
- fmt::ostream moved(std::move(out));
- moved.print("hello");
-}
-
-TEST(OStreamTest, Print) {
- fmt::ostream out = fmt::output_file("test-file");
- out.print("The answer is {}.\n", 42);
- out.close();
- file in("test-file", file::RDONLY);
- EXPECT_READ(in, "The answer is 42.\n");
-}
-
-TEST(OStreamTest, BufferBoundary) {
- auto str = std::string(4096, 'x');
- fmt::ostream out = fmt::output_file("test-file");
- out.print("{}", str);
- out.print("{}", str);
- out.close();
- file in("test-file", file::RDONLY);
- EXPECT_READ(in, str + str);
-}
-
-TEST(OStreamTest, BufferSize) {
- fmt::ostream out = fmt::output_file("test-file", fmt::buffer_size=1);
- out.print("{}", "foo");
- out.close();
- file in("test-file", file::RDONLY);
- EXPECT_READ(in, "foo");
-}
-
+TEST(OStreamTest, Move) {
+ fmt::ostream out = fmt::output_file("test-file");
+ fmt::ostream moved(std::move(out));
+ moved.print("hello");
+}
+
+TEST(OStreamTest, Print) {
+ fmt::ostream out = fmt::output_file("test-file");
+ out.print("The answer is {}.\n", 42);
+ out.close();
+ file in("test-file", file::RDONLY);
+ EXPECT_READ(in, "The answer is 42.\n");
+}
+
+TEST(OStreamTest, BufferBoundary) {
+ auto str = std::string(4096, 'x');
+ fmt::ostream out = fmt::output_file("test-file");
+ out.print("{}", str);
+ out.print("{}", str);
+ out.close();
+ file in("test-file", file::RDONLY);
+ EXPECT_READ(in, str + str);
+}
+
+TEST(OStreamTest, BufferSize) {
+ fmt::ostream out = fmt::output_file("test-file", fmt::buffer_size=1);
+ out.print("{}", "foo");
+ out.close();
+ file in("test-file", file::RDONLY);
+ EXPECT_READ(in, "foo");
+}
+
TEST(FileTest, DefaultCtor) {
file f;
EXPECT_EQ(-1, f.descriptor());
@@ -402,17 +402,17 @@ TEST(FileTest, CloseFileInDtor) {
TEST(FileTest, CloseErrorInDtor) {
std::unique_ptr<file> f(new file(open_file()));
- EXPECT_WRITE(
- stderr,
- {
- // The close function must be called inside EXPECT_WRITE,
- // otherwise the system may recycle closed file descriptor when
- // redirecting the output in EXPECT_STDERR and the second close
- // will break output redirection.
- FMT_POSIX(close(f->descriptor()));
- SUPPRESS_ASSERT(f.reset(nullptr));
- },
- format_system_error(EBADF, "cannot close file") + "\n");
+ EXPECT_WRITE(
+ stderr,
+ {
+ // The close function must be called inside EXPECT_WRITE,
+ // otherwise the system may recycle closed file descriptor when
+ // redirecting the output in EXPECT_STDERR and the second close
+ // will break output redirection.
+ FMT_POSIX(close(f->descriptor()));
+ SUPPRESS_ASSERT(f.reset(nullptr));
+ },
+ format_system_error(EBADF, "cannot close file") + "\n");
}
TEST(FileTest, Close) {
@@ -529,4 +529,4 @@ TEST(LocaleTest, Strtod) {
EXPECT_EQ(start + 3, ptr);
}
# endif
-#endif // FMT_USE_FCNTL
+#endif // FMT_USE_FCNTL
diff --git a/contrib/libs/fmt/test/os-test/ya.make b/contrib/libs/fmt/test/os-test/ya.make
index 95dffb149f..34228bb26b 100644
--- a/contrib/libs/fmt/test/os-test/ya.make
+++ b/contrib/libs/fmt/test/os-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/ostream-test.cc b/contrib/libs/fmt/test/ostream-test.cc
index a038bdfc11..4cef5a78c4 100644
--- a/contrib/libs/fmt/test/ostream-test.cc
+++ b/contrib/libs/fmt/test/ostream-test.cc
@@ -20,10 +20,10 @@ template <> struct formatter<test> : formatter<int> {
};
} // namespace fmt
-#include <sstream>
-
+#include <sstream>
+
#include "fmt/ostream.h"
-#include "fmt/ranges.h"
+#include "fmt/ranges.h"
#include <gmock/gmock.h>
#include "gtest-extra.h"
#include "util.h"
@@ -64,23 +64,23 @@ TEST(OStreamTest, Enum) {
EXPECT_EQ(L"0", fmt::format(L"{}", unstreamable_enum()));
}
-struct test_arg_formatter
- : fmt::detail::arg_formatter<fmt::format_context::iterator, char> {
+struct test_arg_formatter
+ : fmt::detail::arg_formatter<fmt::format_context::iterator, char> {
fmt::format_parse_context parse_ctx;
test_arg_formatter(fmt::format_context& ctx, fmt::format_specs& s)
- : fmt::detail::arg_formatter<fmt::format_context::iterator, char>(
- ctx, &parse_ctx, &s),
- parse_ctx("") {}
+ : fmt::detail::arg_formatter<fmt::format_context::iterator, char>(
+ ctx, &parse_ctx, &s),
+ parse_ctx("") {}
};
TEST(OStreamTest, CustomArg) {
fmt::memory_buffer buffer;
- fmt::format_context ctx(fmt::detail::buffer_appender<char>{buffer},
- fmt::format_args());
+ fmt::format_context ctx(fmt::detail::buffer_appender<char>{buffer},
+ fmt::format_args());
fmt::format_specs spec;
test_arg_formatter af(ctx, spec);
fmt::visit_format_arg(
- af, fmt::detail::make_arg<fmt::format_context>(streamable_enum()));
+ af, fmt::detail::make_arg<fmt::format_context>(streamable_enum()));
EXPECT_EQ("streamable_enum", std::string(buffer.data(), buffer.size()));
}
@@ -96,7 +96,7 @@ TEST(OStreamTest, Format) {
TEST(OStreamTest, FormatSpecs) {
EXPECT_EQ("def ", format("{0:<5}", TestString("def")));
EXPECT_EQ(" def", format("{0:>5}", TestString("def")));
-#if FMT_DEPRECATED_NUMERIC_ALIGN
+#if FMT_DEPRECATED_NUMERIC_ALIGN
EXPECT_THROW_MSG(format("{0:=5}", TestString("def")), format_error,
"format specifier requires numeric argument");
#endif
@@ -141,19 +141,19 @@ TEST(OStreamTest, WriteToOStream) {
fmt::memory_buffer buffer;
const char* foo = "foo";
buffer.append(foo, foo + std::strlen(foo));
- fmt::detail::write_buffer(os, buffer);
+ fmt::detail::write_buffer(os, buffer);
EXPECT_EQ("foo", os.str());
}
TEST(OStreamTest, WriteToOStreamMaxSize) {
- size_t max_size = fmt::detail::max_value<size_t>();
- std::streamsize max_streamsize = fmt::detail::max_value<std::streamsize>();
- if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return;
-
- struct test_buffer final : fmt::detail::buffer<char> {
- explicit test_buffer(size_t size)
- : fmt::detail::buffer<char>(nullptr, size, size) {}
- void grow(size_t) {}
+ size_t max_size = fmt::detail::max_value<size_t>();
+ std::streamsize max_streamsize = fmt::detail::max_value<std::streamsize>();
+ if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return;
+
+ struct test_buffer final : fmt::detail::buffer<char> {
+ explicit test_buffer(size_t size)
+ : fmt::detail::buffer<char>(nullptr, size, size) {}
+ void grow(size_t) {}
} buffer(max_size);
struct mock_streambuf : std::streambuf {
@@ -173,13 +173,13 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
typedef std::make_unsigned<std::streamsize>::type ustreamsize;
ustreamsize size = max_size;
do {
- auto n = std::min(size, fmt::detail::to_unsigned(max_streamsize));
+ auto n = std::min(size, fmt::detail::to_unsigned(max_streamsize));
EXPECT_CALL(streambuf, xsputn(data, static_cast<std::streamsize>(n)))
.WillOnce(testing::Return(max_streamsize));
data += n;
size -= n;
} while (size != 0);
- fmt::detail::write_buffer(os, buffer);
+ fmt::detail::write_buffer(os, buffer);
}
TEST(OStreamTest, Join) {
@@ -260,7 +260,7 @@ TEST(OStreamTest, DisableBuiltinOStreamOperators) {
struct explicitly_convertible_to_string_like {
template <typename String,
typename = typename std::enable_if<std::is_constructible<
- String, const char*, size_t>::value>::type>
+ String, const char*, size_t>::value>::type>
explicit operator String() const {
return String("foo", 3u);
}
@@ -271,13 +271,13 @@ std::ostream& operator<<(std::ostream& os,
return os << "bar";
}
-TEST(OStreamTest, FormatExplicitlyConvertibleToStringLike) {
+TEST(OStreamTest, FormatExplicitlyConvertibleToStringLike) {
EXPECT_EQ("bar", fmt::format("{}", explicitly_convertible_to_string_like()));
}
#ifdef FMT_USE_STRING_VIEW
struct explicitly_convertible_to_std_string_view {
- explicit operator fmt::detail::std_string_view<char>() const {
+ explicit operator fmt::detail::std_string_view<char>() const {
return {"foo", 3u};
}
};
@@ -287,44 +287,44 @@ std::ostream& operator<<(std::ostream& os,
return os << "bar";
}
-TEST(OStreamTest, FormatExplicitlyConvertibleToStdStringView) {
+TEST(OStreamTest, FormatExplicitlyConvertibleToStdStringView) {
EXPECT_EQ("bar", fmt::format("{}", explicitly_convertible_to_string_like()));
}
-#endif // FMT_USE_STRING_VIEW
-
-struct streamable_and_convertible_to_bool {
- operator bool() const { return true; }
-};
-
-std::ostream& operator<<(std::ostream& os, streamable_and_convertible_to_bool) {
- return os << "foo";
-}
-
-TEST(OStreamTest, FormatConvertibleToBool) {
- EXPECT_EQ("foo", fmt::format("{}", streamable_and_convertible_to_bool()));
-}
-
-struct copyfmt_test {};
-
-std::ostream& operator<<(std::ostream& os, copyfmt_test) {
- std::ios ios(nullptr);
- ios.copyfmt(os);
- return os << "foo";
-}
-
-TEST(OStreamTest, CopyFmt) {
- EXPECT_EQ("foo", fmt::format("{}", copyfmt_test()));
-}
-
-TEST(OStreamTest, CompileTimeString) {
- EXPECT_EQ("42", fmt::format(FMT_STRING("{}"), 42));
-}
-
-TEST(OStreamTest, ToString) {
- EXPECT_EQ("ABC", fmt::to_string(fmt_test::ABC()));
-}
-
-TEST(OStreamTest, Range) {
- auto strs = std::vector<TestString>{TestString("foo"), TestString("bar")};
- EXPECT_EQ("{foo, bar}", format("{}", strs));
-} \ No newline at end of file
+#endif // FMT_USE_STRING_VIEW
+
+struct streamable_and_convertible_to_bool {
+ operator bool() const { return true; }
+};
+
+std::ostream& operator<<(std::ostream& os, streamable_and_convertible_to_bool) {
+ return os << "foo";
+}
+
+TEST(OStreamTest, FormatConvertibleToBool) {
+ EXPECT_EQ("foo", fmt::format("{}", streamable_and_convertible_to_bool()));
+}
+
+struct copyfmt_test {};
+
+std::ostream& operator<<(std::ostream& os, copyfmt_test) {
+ std::ios ios(nullptr);
+ ios.copyfmt(os);
+ return os << "foo";
+}
+
+TEST(OStreamTest, CopyFmt) {
+ EXPECT_EQ("foo", fmt::format("{}", copyfmt_test()));
+}
+
+TEST(OStreamTest, CompileTimeString) {
+ EXPECT_EQ("42", fmt::format(FMT_STRING("{}"), 42));
+}
+
+TEST(OStreamTest, ToString) {
+ EXPECT_EQ("ABC", fmt::to_string(fmt_test::ABC()));
+}
+
+TEST(OStreamTest, Range) {
+ auto strs = std::vector<TestString>{TestString("foo"), TestString("bar")};
+ EXPECT_EQ("{foo, bar}", format("{}", strs));
+} \ No newline at end of file
diff --git a/contrib/libs/fmt/test/ostream-test/ya.make b/contrib/libs/fmt/test/ostream-test/ya.make
index d8755c4082..10921b40d1 100644
--- a/contrib/libs/fmt/test/ostream-test/ya.make
+++ b/contrib/libs/fmt/test/ostream-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/posix-mock-test.cc b/contrib/libs/fmt/test/posix-mock-test.cc
index 3f6a06a55b..0ea1b9c6d5 100644
--- a/contrib/libs/fmt/test/posix-mock-test.cc
+++ b/contrib/libs/fmt/test/posix-mock-test.cc
@@ -49,8 +49,8 @@ int pipe_count;
int fopen_count;
int fclose_count;
int fileno_count;
-size_t read_nbyte;
-size_t write_nbyte;
+size_t read_nbyte;
+size_t write_nbyte;
bool sysconf_error;
enum { NONE, MAX_SIZE, ERROR } fstat_sim;
@@ -261,8 +261,8 @@ TEST(FileTest, Size) {
EXPECT_EQ(content.size(), static_cast<unsigned long long>(f.size()));
# ifdef _WIN32
fmt::memory_buffer message;
- fmt::detail::format_windows_error(message, ERROR_ACCESS_DENIED,
- "cannot get file size");
+ fmt::detail::format_windows_error(message, ERROR_ACCESS_DENIED,
+ "cannot get file size");
fstat_sim = ERROR;
EXPECT_THROW_MSG(f.size(), fmt::windows_error, fmt::to_string(message));
fstat_sim = NONE;
@@ -288,7 +288,7 @@ TEST(FileTest, ReadRetry) {
write_end.write("test", SIZE);
write_end.close();
char buffer[SIZE];
- size_t count = 0;
+ size_t count = 0;
EXPECT_RETRY(count = read_end.read(buffer, SIZE), read,
"cannot read from file");
EXPECT_EQ_POSIX(static_cast<std::streamsize>(SIZE), count);
@@ -298,7 +298,7 @@ TEST(FileTest, WriteRetry) {
file read_end, write_end;
file::pipe(read_end, write_end);
enum { SIZE = 4 };
- size_t count = 0;
+ size_t count = 0;
EXPECT_RETRY(count = write_end.write("test", SIZE), write,
"cannot write to file");
write_end.close();
@@ -316,8 +316,8 @@ TEST(FileTest, ConvertReadCount) {
file read_end, write_end;
file::pipe(read_end, write_end);
char c;
- size_t size = UINT_MAX;
- if (sizeof(unsigned) != sizeof(size_t)) ++size;
+ size_t size = UINT_MAX;
+ if (sizeof(unsigned) != sizeof(size_t)) ++size;
read_count = 1;
read_nbyte = 0;
EXPECT_THROW(read_end.read(&c, size), fmt::system_error);
@@ -329,8 +329,8 @@ TEST(FileTest, ConvertWriteCount) {
file read_end, write_end;
file::pipe(read_end, write_end);
char c;
- size_t size = UINT_MAX;
- if (sizeof(unsigned) != sizeof(size_t)) ++size;
+ size_t size = UINT_MAX;
+ if (sizeof(unsigned) != sizeof(size_t)) ++size;
write_count = 1;
write_nbyte = 0;
EXPECT_THROW(write_end.write(&c, size), fmt::system_error);
diff --git a/contrib/libs/fmt/test/posix-mock-test/ya.make b/contrib/libs/fmt/test/posix-mock-test/ya.make
index a8953811d1..d1a55e5200 100644
--- a/contrib/libs/fmt/test/posix-mock-test/ya.make
+++ b/contrib/libs/fmt/test/posix-mock-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
ADDINCL(
diff --git a/contrib/libs/fmt/test/printf-test.cc b/contrib/libs/fmt/test/printf-test.cc
index d8bacbdf27..ccd72dcd75 100644
--- a/contrib/libs/fmt/test/printf-test.cc
+++ b/contrib/libs/fmt/test/printf-test.cc
@@ -17,7 +17,7 @@
using fmt::format;
using fmt::format_error;
-using fmt::detail::max_value;
+using fmt::detail::max_value;
const unsigned BIG_NUM = INT_MAX + 1u;
@@ -113,13 +113,13 @@ TEST(PrintfTest, SwitchArgIndexing) {
TEST(PrintfTest, InvalidArgIndex) {
EXPECT_THROW_MSG(test_sprintf("%0$d", 42), format_error,
- "argument not found");
+ "argument not found");
EXPECT_THROW_MSG(test_sprintf("%2$d", 42), format_error,
- "argument not found");
+ "argument not found");
EXPECT_THROW_MSG(test_sprintf(format("%{}$d", INT_MAX), 42), format_error,
- "argument not found");
+ "argument not found");
- EXPECT_THROW_MSG(test_sprintf("%2$", 42), format_error, "argument not found");
+ EXPECT_THROW_MSG(test_sprintf("%2$", 42), format_error, "argument not found");
EXPECT_THROW_MSG(test_sprintf(format("%{}$d", BIG_NUM), 42), format_error,
"number is too big");
}
@@ -139,11 +139,11 @@ TEST(PrintfTest, ZeroFlag) {
EXPECT_PRINTF("+00042", "%00+6d", 42);
- EXPECT_PRINTF(" 42", "%05.d", 42);
- EXPECT_PRINTF(" 0042", "%05.4d", 42);
-
+ EXPECT_PRINTF(" 42", "%05.d", 42);
+ EXPECT_PRINTF(" 0042", "%05.4d", 42);
+
// '0' flag is ignored for non-numeric types.
- EXPECT_PRINTF(" x", "%05c", 'x');
+ EXPECT_PRINTF(" x", "%05c", 'x');
}
TEST(PrintfTest, PlusFlag) {
@@ -154,38 +154,38 @@ TEST(PrintfTest, PlusFlag) {
// '+' flag is ignored for non-numeric types.
EXPECT_PRINTF("x", "%+c", 'x');
-
- // '+' flag wins over space flag
- EXPECT_PRINTF("+42", "%+ d", 42);
- EXPECT_PRINTF("-42", "%+ d", -42);
- EXPECT_PRINTF("+42", "% +d", 42);
- EXPECT_PRINTF("-42", "% +d", -42);
- EXPECT_PRINTF("+0042", "% +05d", 42);
- EXPECT_PRINTF("+0042", "%0+ 5d", 42);
-
- // '+' flag and space flag are both ignored for non-numeric types.
- EXPECT_PRINTF("x", "%+ c", 'x');
- EXPECT_PRINTF("x", "% +c", 'x');
+
+ // '+' flag wins over space flag
+ EXPECT_PRINTF("+42", "%+ d", 42);
+ EXPECT_PRINTF("-42", "%+ d", -42);
+ EXPECT_PRINTF("+42", "% +d", 42);
+ EXPECT_PRINTF("-42", "% +d", -42);
+ EXPECT_PRINTF("+0042", "% +05d", 42);
+ EXPECT_PRINTF("+0042", "%0+ 5d", 42);
+
+ // '+' flag and space flag are both ignored for non-numeric types.
+ EXPECT_PRINTF("x", "%+ c", 'x');
+ EXPECT_PRINTF("x", "% +c", 'x');
}
TEST(PrintfTest, MinusFlag) {
EXPECT_PRINTF("abc ", "%-5s", "abc");
EXPECT_PRINTF("abc ", "%0--5s", "abc");
-
- EXPECT_PRINTF("7 ", "%-5d", 7);
- EXPECT_PRINTF("97 ", "%-5hhi", 'a');
- EXPECT_PRINTF("a ", "%-5c", 'a');
-
- // '0' flag is ignored if '-' flag is given
- EXPECT_PRINTF("7 ", "%-05d", 7);
- EXPECT_PRINTF("7 ", "%0-5d", 7);
- EXPECT_PRINTF("a ", "%-05c", 'a');
- EXPECT_PRINTF("a ", "%0-5c", 'a');
- EXPECT_PRINTF("97 ", "%-05hhi", 'a');
- EXPECT_PRINTF("97 ", "%0-5hhi", 'a');
-
- // '-' and space flag don't interfere
- EXPECT_PRINTF(" 42", "%- d", 42);
+
+ EXPECT_PRINTF("7 ", "%-5d", 7);
+ EXPECT_PRINTF("97 ", "%-5hhi", 'a');
+ EXPECT_PRINTF("a ", "%-5c", 'a');
+
+ // '0' flag is ignored if '-' flag is given
+ EXPECT_PRINTF("7 ", "%-05d", 7);
+ EXPECT_PRINTF("7 ", "%0-5d", 7);
+ EXPECT_PRINTF("a ", "%-05c", 'a');
+ EXPECT_PRINTF("a ", "%0-5c", 'a');
+ EXPECT_PRINTF("97 ", "%-05hhi", 'a');
+ EXPECT_PRINTF("97 ", "%0-5hhi", 'a');
+
+ // '-' and space flag don't interfere
+ EXPECT_PRINTF(" 42", "%- d", 42);
}
TEST(PrintfTest, SpaceFlag) {
@@ -251,7 +251,7 @@ TEST(PrintfTest, DynamicWidth) {
EXPECT_EQ("42 ", test_sprintf("%*d", -5, 42));
EXPECT_THROW_MSG(test_sprintf("%*d", 5.0, 42), format_error,
"width is not integer");
- EXPECT_THROW_MSG(test_sprintf("%*d"), format_error, "argument not found");
+ EXPECT_THROW_MSG(test_sprintf("%*d"), format_error, "argument not found");
EXPECT_THROW_MSG(test_sprintf("%*d", BIG_NUM, 42), format_error,
"number is too big");
}
@@ -287,11 +287,11 @@ TEST(PrintfTest, FloatPrecision) {
EXPECT_PRINTF(buffer, "%.3a", 1234.5678);
}
-TEST(PrintfTest, StringPrecision) {
- char test[] = {'H', 'e', 'l', 'l', 'o'};
- EXPECT_EQ(fmt::sprintf("%.4s", test), "Hell");
-}
-
+TEST(PrintfTest, StringPrecision) {
+ char test[] = {'H', 'e', 'l', 'l', 'o'};
+ EXPECT_EQ(fmt::sprintf("%.4s", test), "Hell");
+}
+
TEST(PrintfTest, IgnorePrecisionForNonNumericArg) {
EXPECT_PRINTF("abc", "%.5s", "abc");
}
@@ -301,7 +301,7 @@ TEST(PrintfTest, DynamicPrecision) {
EXPECT_EQ("42", test_sprintf("%.*d", -5, 42));
EXPECT_THROW_MSG(test_sprintf("%.*d", 5.0, 42), format_error,
"precision is not integer");
- EXPECT_THROW_MSG(test_sprintf("%.*d"), format_error, "argument not found");
+ EXPECT_THROW_MSG(test_sprintf("%.*d"), format_error, "argument not found");
EXPECT_THROW_MSG(test_sprintf("%.*d", BIG_NUM, 42), format_error,
"number is too big");
if (sizeof(long long) != sizeof(int)) {
@@ -330,7 +330,7 @@ void TestLength(const char* length_spec, U value) {
unsigned long long unsigned_value = 0;
// Apply integer promotion to the argument.
unsigned long long max = max_value<U>();
- using fmt::detail::const_check;
+ using fmt::detail::const_check;
if (const_check(max <= static_cast<unsigned>(max_value<int>()))) {
signed_value = static_cast<int>(value);
unsigned_value = static_cast<unsigned long long>(value);
@@ -399,7 +399,7 @@ TEST(PrintfTest, Length) {
TestLength<long long>("ll");
TestLength<unsigned long long>("ll");
TestLength<intmax_t>("j");
- TestLength<size_t>("z");
+ TestLength<size_t>("z");
TestLength<std::ptrdiff_t>("t");
long double max = max_value<long double>();
EXPECT_PRINTF(fmt::format("{:.6}", max), "%g", max);
@@ -607,22 +607,22 @@ TEST(PrintfTest, VSPrintfMakeWArgsExample) {
#endif
}
-TEST(PrintfTest, PrintfDetermineOutputSize) {
- using backit = std::back_insert_iterator<std::vector<char>>;
- using truncated_printf_context =
- fmt::basic_printf_context<fmt::detail::truncating_iterator<backit>, char>;
+TEST(PrintfTest, PrintfDetermineOutputSize) {
+ using backit = std::back_insert_iterator<std::vector<char>>;
+ using truncated_printf_context =
+ fmt::basic_printf_context<fmt::detail::truncating_iterator<backit>, char>;
- auto v = std::vector<char>{};
- auto it = std::back_inserter(v);
+ auto v = std::vector<char>{};
+ auto it = std::back_inserter(v);
- const auto format_string = "%s";
- const auto format_arg = "Hello";
- const auto expected_size = fmt::sprintf(format_string, format_arg).size();
+ const auto format_string = "%s";
+ const auto format_arg = "Hello";
+ const auto expected_size = fmt::sprintf(format_string, format_arg).size();
- EXPECT_EQ((truncated_printf_context(
- fmt::detail::truncating_iterator<backit>(it, 0), format_string,
- fmt::make_format_args<truncated_printf_context>(format_arg))
- .format()
- .count()),
- expected_size);
+ EXPECT_EQ((truncated_printf_context(
+ fmt::detail::truncating_iterator<backit>(it, 0), format_string,
+ fmt::make_format_args<truncated_printf_context>(format_arg))
+ .format()
+ .count()),
+ expected_size);
}
diff --git a/contrib/libs/fmt/test/printf-test/ya.make b/contrib/libs/fmt/test/printf-test/ya.make
index 8c71429829..ec264a6c81 100644
--- a/contrib/libs/fmt/test/printf-test/ya.make
+++ b/contrib/libs/fmt/test/printf-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/ranges-test.cc b/contrib/libs/fmt/test/ranges-test.cc
index fb3c9b45d1..394f7b81be 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
diff --git a/contrib/libs/fmt/test/ranges-test/ya.make b/contrib/libs/fmt/test/ranges-test/ya.make
index f19426cc90..6856e12893 100644
--- a/contrib/libs/fmt/test/ranges-test/ya.make
+++ b/contrib/libs/fmt/test/ranges-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/scan-test.cc b/contrib/libs/fmt/test/scan-test.cc
index 925839b6fd..90c0edef9b 100644
--- a/contrib/libs/fmt/test/scan-test.cc
+++ b/contrib/libs/fmt/test/scan-test.cc
@@ -5,10 +5,10 @@
//
// For the license information refer to format.h.
-#include "scan.h"
-
+#include "scan.h"
+
#include <time.h>
-
+
#include <climits>
#include <gmock/gmock.h>
@@ -75,7 +75,7 @@ template <> struct scanner<tm> {
if (it != ctx.end() && *it == ':') ++it;
auto end = it;
while (end != ctx.end() && *end != '}') ++end;
- format.reserve(detail::to_unsigned(end - it + 1));
+ format.reserve(detail::to_unsigned(end - it + 1));
format.append(it, end);
format.push_back('\0');
return end;
diff --git a/contrib/libs/fmt/test/scan-test/ya.make b/contrib/libs/fmt/test/scan-test/ya.make
index e019ffeee9..2a3a49bd9a 100644
--- a/contrib/libs/fmt/test/scan-test/ya.make
+++ b/contrib/libs/fmt/test/scan-test/ya.make
@@ -1,14 +1,14 @@
# Generated by devtools/yamaker.
-GTEST()
+GTEST()
-WITHOUT_LICENSE_TEXTS()
+WITHOUT_LICENSE_TEXTS()
+
+OWNER(
+ orivej
+ g:cpp-contrib
+)
-OWNER(
- orivej
- g:cpp-contrib
-)
-
LICENSE(MIT)
PEERDIR(
diff --git a/contrib/libs/fmt/test/scan.h b/contrib/libs/fmt/test/scan.h
index 4c0a5d8fc1..de82067a49 100644
--- a/contrib/libs/fmt/test/scan.h
+++ b/contrib/libs/fmt/test/scan.h
@@ -31,7 +31,7 @@ class scan_parse_context {
FMT_CONSTEXPR iterator end() const { return format_.end(); }
void advance_to(iterator it) {
- format_.remove_prefix(detail::to_unsigned(it - begin()));
+ format_.remove_prefix(detail::to_unsigned(it - begin()));
}
};
@@ -48,11 +48,11 @@ struct scan_context {
iterator end() const { return begin() + input_.size(); }
void advance_to(iterator it) {
- input_.remove_prefix(detail::to_unsigned(it - begin()));
+ input_.remove_prefix(detail::to_unsigned(it - begin()));
}
};
-namespace detail {
+namespace detail {
enum class scan_type {
none_type,
int_type,
@@ -107,20 +107,20 @@ class scan_arg {
ctx.advance_to(s.scan(*static_cast<T*>(arg), ctx));
}
};
-} // namespace detail
+} // namespace detail
struct scan_args {
int size;
- const detail::scan_arg* data;
+ const detail::scan_arg* data;
template <size_t N>
- scan_args(const std::array<detail::scan_arg, N>& store)
+ scan_args(const std::array<detail::scan_arg, N>& store)
: size(N), data(store.data()) {
static_assert(N < INT_MAX, "too many arguments");
}
};
-namespace detail {
+namespace detail {
struct scan_handler : error_handler {
private:
@@ -169,15 +169,15 @@ struct scan_handler : error_handler {
scan_ctx_.advance_to(it + size);
}
- int on_arg_id() { return on_arg_id(next_arg_id_++); }
- int on_arg_id(int id) {
+ int on_arg_id() { return on_arg_id(next_arg_id_++); }
+ int on_arg_id(int id) {
if (id >= args_.size) on_error("argument index out of range");
arg_ = args_.data[id];
- return id;
+ return id;
}
- int on_arg_id(string_view) { return on_error("invalid format"), 0; }
+ int on_arg_id(string_view) { return on_error("invalid format"), 0; }
- void on_replacement_field(int, const char*) {
+ void on_replacement_field(int, const char*) {
auto it = scan_ctx_.begin(), end = scan_ctx_.end();
switch (arg_.type) {
case scan_type::int_type:
@@ -209,24 +209,24 @@ struct scan_handler : error_handler {
}
}
- const char* on_format_specs(int, const char* begin, const char*) {
+ const char* on_format_specs(int, const char* begin, const char*) {
if (arg_.type != scan_type::custom_type) return begin;
parse_ctx_.advance_to(begin);
arg_.custom.scan(arg_.custom.value, parse_ctx_, scan_ctx_);
return parse_ctx_.begin();
}
};
-} // namespace detail
+} // namespace detail
template <typename... Args>
-std::array<detail::scan_arg, sizeof...(Args)> make_scan_args(Args&... args) {
+std::array<detail::scan_arg, sizeof...(Args)> make_scan_args(Args&... args) {
return {{args...}};
}
string_view::iterator vscan(string_view input, string_view format_str,
scan_args args) {
- detail::scan_handler h(format_str, input, args);
- detail::parse_format_string<false>(format_str, h);
+ detail::scan_handler h(format_str, input, args);
+ detail::parse_format_string<false>(format_str, h);
return input.begin() + (h.pos() - &*input.begin());
}
diff --git a/contrib/libs/fmt/test/test-assert.h b/contrib/libs/fmt/test/test-assert.h
index ecd9b8dc15..f9df580539 100644
--- a/contrib/libs/fmt/test/test-assert.h
+++ b/contrib/libs/fmt/test/test-assert.h
@@ -9,7 +9,7 @@
#define FMT_TEST_ASSERT_H_
#include <stdexcept>
-
+
#include <gtest/gtest.h>
class assertion_failure : public std::logic_error {
diff --git a/contrib/libs/fmt/test/util.cc b/contrib/libs/fmt/test/util.cc
index c4b89d8e19..d08dcbdcbf 100644
--- a/contrib/libs/fmt/test/util.cc
+++ b/contrib/libs/fmt/test/util.cc
@@ -6,7 +6,7 @@
// For the license information refer to format.h.
#include "util.h"
-
+
#include <cstring>
void increment(char* s) {
diff --git a/contrib/libs/fmt/test/util.h b/contrib/libs/fmt/test/util.h
index 589ca94993..24a5f4e34b 100644
--- a/contrib/libs/fmt/test/util.h
+++ b/contrib/libs/fmt/test/util.h
@@ -19,7 +19,7 @@ enum { BUFFER_SIZE = 256 };
# define FMT_VSNPRINTF vsnprintf
#endif
-template <size_t SIZE>
+template <size_t SIZE>
void safe_sprintf(char (&buffer)[SIZE], const char* format, ...) {
std::va_list args;
va_start(args, format);
diff --git a/contrib/libs/fmt/test/ya.make b/contrib/libs/fmt/test/ya.make
index c21fef22a1..8db82d6c1e 100644
--- a/contrib/libs/fmt/test/ya.make
+++ b/contrib/libs/fmt/test/ya.make
@@ -12,7 +12,7 @@ OWNER(
LICENSE(MIT)
PEERDIR(
- contrib/libs/fmt
+ contrib/libs/fmt
contrib/restricted/googletest/googlemock
)