aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/fmt/test/os-test.cc
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/os-test.cc
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/os-test.cc')
-rw-r--r--contrib/libs/fmt/test/os-test.cc148
1 files changed, 74 insertions, 74 deletions
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