diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-09-15 21:15:53 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-09-15 21:15:53 +0200 |
| commit | aa49abdf239bae6065fddd0839ec67a404c9748c (patch) | |
| tree | 631fbb2df58aa35df3d60c65c037ef74b1807114 /test | |
| parent | bf41a601fd0447bcf3a2937a595a1cd8ca5c1633 (diff) | |
Add .clang-format
Make it easier to keep a consistent style
Diffstat (limited to 'test')
| -rw-r--r-- | test/args.cc | 138 | ||||
| -rw-r--r-- | test/buffer.cc | 10 | ||||
| -rw-r--r-- | test/csv.cc | 4 | ||||
| -rw-r--r-- | test/decompress.cc | 60 | ||||
| -rw-r--r-- | test/io.cc | 20 | ||||
| -rw-r--r-- | test/io_test_helper.cc | 6 | ||||
| -rw-r--r-- | test/io_test_helper.hh | 2 | ||||
| -rw-r--r-- | test/line.cc | 24 | ||||
| -rw-r--r-- | test/str.cc | 4 | ||||
| -rw-r--r-- | test/u.cc | 53 | ||||
| -rw-r--r-- | test/uio.cc | 269 |
11 files changed, 297 insertions, 293 deletions
diff --git a/test/args.cc b/test/args.cc index a43c59c..22159d2 100644 --- a/test/args.cc +++ b/test/args.cc @@ -1,8 +1,7 @@ -#include <gtest/gtest.h> - #include "args.hh" #include <cstddef> +#include <gtest/gtest.h> #include <memory> #include <sstream> #include <string> @@ -10,17 +9,17 @@ #include <utility> #include <vector> -#define SETUP_OPTIONS(args) \ - auto short_only = (args)->option('a', "", "an option"); \ - auto short_long = (args)->option('b', "bold", "set font style to bold"); \ - auto long_only = (args)->option("cold", "use if it is cold outside"); \ - auto short_only_req = (args)->option_argument('d', "", "", "distance"); \ - auto short_long_req = (args)->option_argument( \ - 'e', "eat", "FOOD", "what to order, what to eat?"); \ - auto long_only_req = (args)->option_argument( \ - "form", "", "circle, shape or something else?"); \ - auto short_only_opt = (args)->option_argument('g', "", "", "", false); \ - auto short_long_opt = (args)->option_argument('h', "hold", "", "", false); \ +#define SETUP_OPTIONS(args) \ + auto short_only = (args)->option('a', "", "an option"); \ + auto short_long = (args)->option('b', "bold", "set font style to bold"); \ + auto long_only = (args)->option("cold", "use if it is cold outside"); \ + auto short_only_req = (args)->option_argument('d', "", "", "distance"); \ + auto short_long_req = (args)->option_argument( \ + 'e', "eat", "FOOD", "what to order, what to eat?"); \ + auto long_only_req = \ + (args)->option_argument("form", "", "circle, shape or something else?"); \ + auto short_only_opt = (args)->option_argument('g', "", "", "", false); \ + auto short_long_opt = (args)->option_argument('h', "hold", "", "", false); \ auto long_only_opt = (args)->option_argument("invert", "", "", false); namespace { @@ -30,8 +29,7 @@ class Arguments { [[nodiscard]] int c() const { return static_cast<int>(str_.size()); }; [[nodiscard]] char** v() const { return ptr_.get(); } - explicit Arguments(std::vector<std::string> str) - : str_(std::move(str)) { + explicit Arguments(std::vector<std::string> str) : str_(std::move(str)) { ptr_ = std::make_unique<char*[]>(str_.size()); for (size_t i = 0; i < str_.size(); ++i) { ptr_[i] = const_cast<char*>(str_[i].c_str()); @@ -48,9 +46,7 @@ class Arguments { class Builder { public: - Arguments build() { - return Arguments(std::move(str_)); - } + Arguments build() { return Arguments(std::move(str_)); } Builder& add(std::string str) { str_.emplace_back(std::move(str)); @@ -110,16 +106,18 @@ TEST(args, options_set) { SETUP_OPTIONS(args); Builder builder; auto arg = builder.add("foo") - .add("-a") - .add("-b") - .add("--cold") - .add("-d").add("10") - .add("-e").add("hamburger") - .add("--form=circle") - .add("-g") - .add("-h") - .add("--invert") - .build(); + .add("-a") + .add("-b") + .add("--cold") + .add("-d") + .add("10") + .add("-e") + .add("hamburger") + .add("--form=circle") + .add("-g") + .add("-h") + .add("--invert") + .build(); std::vector<std::string_view> out; EXPECT_TRUE(args->run(arg.c(), arg.v(), &out)); EXPECT_TRUE(out.empty()); @@ -148,16 +146,18 @@ TEST(args, options_set_variant) { SETUP_OPTIONS(args); Builder builder; auto arg = builder.add("foo") - .add("-a") - .add("--bold") - .add("--cold") - .add("-d").add("10") - .add("--eat=hamburger") - .add("--form").add("circle") - .add("-g") - .add("--hold=foo") - .add("--invert=bar") - .build(); + .add("-a") + .add("--bold") + .add("--cold") + .add("-d") + .add("10") + .add("--eat=hamburger") + .add("--form") + .add("circle") + .add("-g") + .add("--hold=foo") + .add("--invert=bar") + .build(); std::vector<std::string_view> out; EXPECT_TRUE(args->run(arg.c(), arg.v(), &out)); EXPECT_TRUE(out.empty()); @@ -187,9 +187,7 @@ TEST(args, options_short_missing_value) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("-d") - .build(); + auto arg = builder.add("foo").add("-d").build(); EXPECT_FALSE(args->run(arg.c(), arg.v())); std::stringstream ss; args->print_error(ss); @@ -200,9 +198,7 @@ TEST(args, options_short_unknown_value) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("-X") - .build(); + auto arg = builder.add("foo").add("-X").build(); EXPECT_FALSE(args->run(arg.c(), arg.v())); std::stringstream ss; args->print_error(ss); @@ -213,9 +209,7 @@ TEST(args, options_long_missing_value) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("--form") - .build(); + auto arg = builder.add("foo").add("--form").build(); EXPECT_FALSE(args->run(arg.c(), arg.v())); std::stringstream ss; args->print_error(ss); @@ -226,9 +220,7 @@ TEST(args, options_long_unsupported_value) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("--cold=feet") - .build(); + auto arg = builder.add("foo").add("--cold=feet").build(); EXPECT_FALSE(args->run(arg.c(), arg.v())); std::stringstream ss; args->print_error(ss); @@ -239,9 +231,7 @@ TEST(args, options_long_unknown_value) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("--experience") - .build(); + auto arg = builder.add("foo").add("--experience").build(); EXPECT_FALSE(args->run(arg.c(), arg.v())); std::stringstream ss; args->print_error(ss); @@ -252,9 +242,7 @@ TEST(args, options_short_dash_value) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("-d").add("-") - .build(); + auto arg = builder.add("foo").add("-d").add("-").build(); std::vector<std::string_view> out; EXPECT_TRUE(args->run(arg.c(), arg.v(), &out)); EXPECT_TRUE(out.empty()); @@ -267,9 +255,7 @@ TEST(args, options_long_dash_dash_value) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("--eat").add("--") - .build(); + auto arg = builder.add("foo").add("--eat").add("--").build(); std::vector<std::string_view> out; EXPECT_TRUE(args->run(arg.c(), arg.v(), &out)); EXPECT_TRUE(out.empty()); @@ -283,11 +269,13 @@ TEST(args, options_dash_dash) { SETUP_OPTIONS(args); Builder builder; auto arg = builder.add("foo") - .add("--") - .add("-d").add("10") - .add("--eat=hamburger") - .add("--form").add("circle") - .build(); + .add("--") + .add("-d") + .add("10") + .add("--eat=hamburger") + .add("--form") + .add("circle") + .build(); std::vector<std::string_view> out; EXPECT_TRUE(args->run(arg.c(), arg.v(), &out)); ASSERT_EQ(5, out.size()); @@ -305,9 +293,7 @@ TEST(args, options_dash_dash_end) { auto args = Args::create(); SETUP_OPTIONS(args); Builder builder; - auto arg = builder.add("foo") - .add("--") - .build(); + auto arg = builder.add("foo").add("--").build(); std::vector<std::string_view> out; EXPECT_TRUE(args->run(arg.c(), arg.v(), &out)); EXPECT_TRUE(out.empty()); @@ -330,7 +316,8 @@ TEST(args, help) { -g -h, --hold=[ARG] --invert=[ARG] -)", ss.str()); +)", + ss.str()); } TEST(args, help_wide) { @@ -338,7 +325,8 @@ TEST(args, help_wide) { SETUP_OPTIONS(args); std::stringstream ss; args->print_help(ss, 100); - EXPECT_EQ(R"(Mandatory arguments to long options are mandatory for short options too. + EXPECT_EQ( + R"(Mandatory arguments to long options are mandatory for short options too. -a an option -b, --bold set font style to bold --cold use if it is cold outside @@ -348,7 +336,8 @@ TEST(args, help_wide) { -g -h, --hold=[ARG] --invert=[ARG] -)", ss.str()); +)", + ss.str()); } TEST(args, help_narrow) { @@ -372,7 +361,8 @@ circle, shape or something else? -g -h, --hold=[ARG] --invert=[ARG] -)", ss.str()); +)", + ss.str()); } TEST(args, help_very_narrow) { @@ -401,7 +391,8 @@ circle, shape or -g -h, --hold=[ARG] --invert=[ARG] -)", ss.str()); +)", + ss.str()); } TEST(args, help_long_word) { @@ -416,5 +407,6 @@ TEST(args, help_long_word) { -a, --arg aaaaaaaaaaaaaaaaaaa- aaaaaaaaaaaaaaaaaaa -)", ss.str()); +)", + ss.str()); } diff --git a/test/buffer.cc b/test/buffer.cc index e747fb7..897bd88 100644 --- a/test/buffer.cc +++ b/test/buffer.cc @@ -1,9 +1,8 @@ -#include <gtest/gtest.h> - #include "buffer.hh" #include <cstdint> #include <cstring> +#include <gtest/gtest.h> #include <memory> #include <utility> @@ -240,10 +239,9 @@ TEST_P(BufferTest, full) { buffer->consume(0); } -INSTANTIATE_TEST_SUITE_P( - AllTypes, - BufferTest, - testing::Values(BufferType::Fixed, BufferType::Dynamic)); +INSTANTIATE_TEST_SUITE_P(AllTypes, BufferTest, + testing::Values(BufferType::Fixed, + BufferType::Dynamic)); TEST(buffer, dynamic_increase) { auto buffer = Buffer::dynamic(10, 20); diff --git a/test/csv.cc b/test/csv.cc index 49fe540..b915006 100644 --- a/test/csv.cc +++ b/test/csv.cc @@ -1,7 +1,7 @@ -#include <gtest/gtest.h> - #include "csv.hh" +#include <gtest/gtest.h> + TEST(csv, empty) { auto csv = csv::open(io::memory("")); auto line = csv->read(); diff --git a/test/decompress.cc b/test/decompress.cc index 35c4477..df1d08c 100644 --- a/test/decompress.cc +++ b/test/decompress.cc @@ -1,16 +1,14 @@ -#include <gtest/gtest.h> - #include "decompress.hh" +#include <gtest/gtest.h> + TEST(z_decompress, empty) { - static const unsigned char data[] = { - 0x1f, 0x8b, 0x08, 0x08, 0x33, 0xd4, 0xbd, 0x68, - 0x02, 0x03, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 - }; - auto reader = decompress::gzip(io::memory(std::string( - reinterpret_cast<const char*>(data), sizeof(data)))); + static const unsigned char data[] = {0x1f, 0x8b, 0x08, 0x08, 0x33, 0xd4, 0xbd, + 0x68, 0x02, 0x03, 0x65, 0x6d, 0x70, 0x74, + 0x79, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00}; + auto reader = decompress::gzip(io::memory( + std::string(reinterpret_cast<const char*>(data), sizeof(data)))); char buf[10]; auto got = reader->read(buf, sizeof(buf)); ASSERT_TRUE(got.has_value()); @@ -19,13 +17,12 @@ TEST(z_decompress, empty) { TEST(z_decompress, hello) { static const unsigned char data[] = { - 0x1f, 0x8b, 0x08, 0x08, 0xf7, 0xd5, 0xbd, 0x68, - 0x02, 0x03, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, - 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x07, 0x00, 0x82, - 0x89, 0xd1, 0xf7, 0x05, 0x00, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x08, 0xf7, 0xd5, 0xbd, 0x68, 0x02, 0x03, 0x68, + 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x07, + 0x00, 0x82, 0x89, 0xd1, 0xf7, 0x05, 0x00, 0x00, 0x00, }; - auto reader = decompress::gzip(io::memory(std::string( - reinterpret_cast<const char*>(data), sizeof(data)))); + auto reader = decompress::gzip(io::memory( + std::string(reinterpret_cast<const char*>(data), sizeof(data)))); char buf[10]; auto got = reader->read(buf, sizeof(buf)); ASSERT_TRUE(got.has_value()); @@ -36,13 +33,11 @@ TEST(z_decompress, hello) { TEST(xz_decompress, empty) { static const unsigned char data[] = { - 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, - 0xe6, 0xd6, 0xb4, 0x46, 0x00, 0x00, 0x00, 0x00, - 0x1c, 0xdf, 0x44, 0x21, 0x1f, 0xb6, 0xf3, 0x7d, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x59, 0x5a - }; - auto reader = decompress::xz(io::memory(std::string( - reinterpret_cast<const char*>(data), sizeof(data)))); + 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, 0xe6, 0xd6, 0xb4, + 0x46, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xdf, 0x44, 0x21, 0x1f, 0xb6, + 0xf3, 0x7d, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x59, 0x5a}; + auto reader = decompress::xz(io::memory( + std::string(reinterpret_cast<const char*>(data), sizeof(data)))); char buf[10]; auto got = reader->read(buf, sizeof(buf)); ASSERT_TRUE(got.has_value()); @@ -51,18 +46,15 @@ TEST(xz_decompress, empty) { TEST(xz_decompress, hello) { static const unsigned char data[] = { - 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, - 0xe6, 0xd6, 0xb4, 0x46, 0x04, 0xc0, 0x09, 0x05, - 0x21, 0x01, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x76, 0xe9, 0x07, 0x70, - 0x01, 0x00, 0x04, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x00, 0x00, 0x00, 0x00, 0xc8, 0xac, 0x7b, 0xc8, - 0x3b, 0x5c, 0xcf, 0x51, 0x00, 0x01, 0x25, 0x05, - 0x43, 0x91, 0x1f, 0xb8, 0x1f, 0xb6, 0xf3, 0x7d, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x59, 0x5a, + 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, 0xe6, 0xd6, 0xb4, 0x46, + 0x04, 0xc0, 0x09, 0x05, 0x21, 0x01, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x76, 0xe9, 0x07, 0x70, 0x01, 0x00, 0x04, 0x48, + 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xac, 0x7b, 0xc8, + 0x3b, 0x5c, 0xcf, 0x51, 0x00, 0x01, 0x25, 0x05, 0x43, 0x91, 0x1f, 0xb8, + 0x1f, 0xb6, 0xf3, 0x7d, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x59, 0x5a, }; - auto reader = decompress::xz(io::memory(std::string( - reinterpret_cast<const char*>(data), sizeof(data)))); + auto reader = decompress::xz(io::memory( + std::string(reinterpret_cast<const char*>(data), sizeof(data)))); char buf[10]; auto got = reader->read(buf, sizeof(buf)); ASSERT_TRUE(got.has_value()); @@ -1,12 +1,12 @@ -#include <gtest/gtest.h> - #include "io.hh" + #include "io_test_helper.hh" #include <cerrno> #include <cstdlib> #include <dirent.h> #include <fcntl.h> +#include <gtest/gtest.h> #include <sys/stat.h> #include <unistd.h> #include <utility> @@ -15,11 +15,14 @@ namespace { bool remove_recursive(int fd) { auto* dir = fdopendir(fd); - if (!dir) return false; + if (!dir) + return false; while (auto* ent = readdir(dir)) { if (ent->d_name[0] == '.') { - if (ent->d_name[1] == '\0') continue; - if (ent->d_name[1] == '.' && ent->d_name[2] == '\0') continue; + if (ent->d_name[1] == '\0') + continue; + if (ent->d_name[1] == '.' && ent->d_name[2] == '\0') + continue; } bool is_dir; if (ent->d_type == DT_DIR) { @@ -86,14 +89,13 @@ class IoTest : public testing::Test { rmdir(tmpdir_.c_str()); } - [[nodiscard]] int dirfd() const { - return dirfd_; - } + [[nodiscard]] int dirfd() const { return dirfd_; } void touch(const std::string& name, const std::string& value = "") { auto fd = openat(dirfd(), name.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0700); EXPECT_NE(-1, fd); - if (fd == -1) return; + if (fd == -1) + return; size_t offset = 0; while (offset < value.size()) { auto ret = write(fd, value.data() + offset, value.size() - offset); diff --git a/test/io_test_helper.cc b/test/io_test_helper.cc index 514e888..9ac663a 100644 --- a/test/io_test_helper.cc +++ b/test/io_test_helper.cc @@ -70,9 +70,9 @@ class MaxBlockReader : public io::Reader { } // namespace -std::unique_ptr<io::Reader> io_make_breaking( - std::unique_ptr<io::Reader> reader, size_t offset, - io::ReadError error) { +std::unique_ptr<io::Reader> io_make_breaking(std::unique_ptr<io::Reader> reader, + size_t offset, + io::ReadError error) { return std::make_unique<BreakingReader>(std::move(reader), offset, error); } diff --git a/test/io_test_helper.hh b/test/io_test_helper.hh index ce191cf..b99b8fa 100644 --- a/test/io_test_helper.hh +++ b/test/io_test_helper.hh @@ -1,7 +1,7 @@ #ifndef IO_TEST_HELPER_HH #define IO_TEST_HELPER_HH -#include "io.hh" // IWYU pragma: export +#include "io.hh" // IWYU pragma: export #include <cstddef> #include <memory> diff --git a/test/line.cc b/test/line.cc index 0f90723..71d75c5 100644 --- a/test/line.cc +++ b/test/line.cc @@ -1,9 +1,9 @@ -#include <gtest/gtest.h> +#include "line.hh" #include "io_test_helper.hh" -#include "line.hh" #include <cstddef> +#include <gtest/gtest.h> #include <limits> #include <utility> @@ -124,9 +124,8 @@ TEST(line, read_error_newline) { } TEST(line, blocky) { - auto reader = line::open( - io_make_max_block(io::memory("foo bar\r\nfim zam"), - /* max_block_size */ 1)); + auto reader = line::open(io_make_max_block(io::memory("foo bar\r\nfim zam"), + /* max_block_size */ 1)); auto line = reader->read(); ASSERT_TRUE(line.has_value()); EXPECT_EQ("foo bar", line.value()); @@ -139,9 +138,8 @@ TEST(line, blocky) { } TEST(line, blocky_newline) { - auto reader = line::open( - io_make_max_block(io::memory("foo bar\r\nfim zam"), - /* max_block_size */ 8)); + auto reader = line::open(io_make_max_block(io::memory("foo bar\r\nfim zam"), + /* max_block_size */ 8)); auto line = reader->read(); ASSERT_TRUE(line.has_value()); EXPECT_EQ("foo bar", line.value()); @@ -177,8 +175,10 @@ TEST(line, max_newline) { } TEST(line, max_line_overflow) { - EXPECT_DEATH_IF_SUPPORTED({ - std::ignore = line::open(io::memory(""), - std::numeric_limits<size_t>::max()); - }, ""); + EXPECT_DEATH_IF_SUPPORTED( + { + std::ignore = + line::open(io::memory(""), std::numeric_limits<size_t>::max()); + }, + ""); } diff --git a/test/str.cc b/test/str.cc index 35d70d7..1339bb0 100644 --- a/test/str.cc +++ b/test/str.cc @@ -1,7 +1,7 @@ -#include <gtest/gtest.h> - #include "str.hh" +#include <gtest/gtest.h> + TEST(str, split) { auto ret = str::split(""); EXPECT_EQ(0, ret.size()); @@ -1,16 +1,14 @@ -#include <gtest/gtest.h> - +#include "u16.hh" #include "u8.hh" #include "umod8.hh" -#include "u16.hh" +#include <gtest/gtest.h> #include <iterator> #include <vector> namespace { -class UnicodeVersionTest : public testing::TestWithParam<u::Version> { -}; +class UnicodeVersionTest : public testing::TestWithParam<u::Version> {}; } // namespace @@ -389,8 +387,7 @@ TEST(umod8, examples) { } } -TEST(umod8, overlong) { -} +TEST(umod8, overlong) {} TEST(umod8, incomplete) { { @@ -709,8 +706,7 @@ TEST_P(UnicodeVersionTest, lookup_gc) { u::GeneralCategory::LETTER_TITLECASE); EXPECT_EQ(u::lookup_gc(0x374, GetParam()), u::GeneralCategory::LETTER_MODIFIER); - EXPECT_EQ(u::lookup_gc(0x34ff, GetParam()), - u::GeneralCategory::LETTER_OTHER); + EXPECT_EQ(u::lookup_gc(0x34ff, GetParam()), u::GeneralCategory::LETTER_OTHER); EXPECT_EQ(u::lookup_gc(0x483, GetParam()), u::GeneralCategory::MARK_NONSPACING); @@ -719,12 +715,10 @@ TEST_P(UnicodeVersionTest, lookup_gc) { EXPECT_EQ(u::lookup_gc(0x20de, GetParam()), u::GeneralCategory::MARK_SPACING_ENCLOSING); - EXPECT_EQ(u::lookup_gc(0xa620, GetParam()), - u::GeneralCategory::NUMBER_DIGIT); + EXPECT_EQ(u::lookup_gc(0xa620, GetParam()), u::GeneralCategory::NUMBER_DIGIT); EXPECT_EQ(u::lookup_gc(0xa6e6, GetParam()), u::GeneralCategory::NUMBER_LETTER); - EXPECT_EQ(u::lookup_gc(0xa830, GetParam()), - u::GeneralCategory::NUMBER_OTHER); + EXPECT_EQ(u::lookup_gc(0xa830, GetParam()), u::GeneralCategory::NUMBER_OTHER); EXPECT_EQ(u::lookup_gc(0xfe33, GetParam()), u::GeneralCategory::PUNCTUATION_CONNECTOR); @@ -741,14 +735,12 @@ TEST_P(UnicodeVersionTest, lookup_gc) { EXPECT_EQ(u::lookup_gc(0xff1a, GetParam()), u::GeneralCategory::PUNCTUATION_OTHER); - EXPECT_EQ(u::lookup_gc(0xd7, GetParam()), - u::GeneralCategory::SYMBOL_MATH); + EXPECT_EQ(u::lookup_gc(0xd7, GetParam()), u::GeneralCategory::SYMBOL_MATH); EXPECT_EQ(u::lookup_gc(0x58f, GetParam()), u::GeneralCategory::SYMBOL_CURRENCY); EXPECT_EQ(u::lookup_gc(0x5e, GetParam()), u::GeneralCategory::SYMBOL_MODIFIER); - EXPECT_EQ(u::lookup_gc(0xf03, GetParam()), - u::GeneralCategory::SYMBOL_OTHER); + EXPECT_EQ(u::lookup_gc(0xf03, GetParam()), u::GeneralCategory::SYMBOL_OTHER); EXPECT_EQ(u::lookup_gc(0x20, GetParam()), u::GeneralCategory::SEPARATOR_SPACE); @@ -757,10 +749,8 @@ TEST_P(UnicodeVersionTest, lookup_gc) { EXPECT_EQ(u::lookup_gc(0x2029, GetParam()), u::GeneralCategory::SEPARATOR_PARAGRAPH); - EXPECT_EQ(u::lookup_gc(0xa, GetParam()), - u::GeneralCategory::OTHER_CONTROL); - EXPECT_EQ(u::lookup_gc(0x202d, GetParam()), - u::GeneralCategory::OTHER_FORMAT); + EXPECT_EQ(u::lookup_gc(0xa, GetParam()), u::GeneralCategory::OTHER_CONTROL); + EXPECT_EQ(u::lookup_gc(0x202d, GetParam()), u::GeneralCategory::OTHER_FORMAT); EXPECT_EQ(u::lookup_gc(0xd800, GetParam()), u::GeneralCategory::OTHER_SURROGATE); EXPECT_EQ(u::lookup_gc(0xdbff, GetParam()), @@ -775,18 +765,9 @@ TEST_P(UnicodeVersionTest, lookup_gc) { } INSTANTIATE_TEST_SUITE_P( - AllVersions, - UnicodeVersionTest, - testing::Values( - u::Version::u6_2_0, - u::Version::u8_0_0, - u::Version::u10_0_0, - u::Version::u11_0_0, - u::Version::u12_1_0, - u::Version::u13_0_0, - u::Version::u14_0_0, - u::Version::u15_0_0, - u::Version::u15_1_0, - u::Version::u16_0_0 - ) -); + AllVersions, UnicodeVersionTest, + testing::Values(u::Version::u6_2_0, u::Version::u8_0_0, u::Version::u10_0_0, + u::Version::u11_0_0, u::Version::u12_1_0, + u::Version::u13_0_0, u::Version::u14_0_0, + u::Version::u15_0_0, u::Version::u15_1_0, + u::Version::u16_0_0)); diff --git a/test/uio.cc b/test/uio.cc index ce666c1..7c8d175 100644 --- a/test/uio.cc +++ b/test/uio.cc @@ -1,9 +1,9 @@ -#include <gtest/gtest.h> +#include "uio.hh" #include "io.hh" #include "io_test_helper.hh" -#include "uio.hh" +#include <gtest/gtest.h> #include <string> using namespace std::literals::string_literals; @@ -25,18 +25,23 @@ TEST(uio_u16, empty) { } TEST(uio_u8, sample) { - auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" "es"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF8}); + auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" + "es"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF8}); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); EXPECT_EQ(6, ret.value()); - EXPECT_EQ("\xf0\x90\x8D\x85" "es", tmp); + EXPECT_EQ( + "\xf0\x90\x8D\x85" + "es", + tmp); } TEST(uio_u16, sample_be) { - auto uio = u16::open(io::memory("\x00\x24\xD8\x01\xDC\x37"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_BE}); + auto uio = + u16::open(io::memory("\x00\x24\xD8\x01\xDC\x37"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_BE}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -47,8 +52,9 @@ TEST(uio_u16, sample_be) { } TEST(uio_u16, sample_le) { - auto uio = u16::open(io::memory("\x24\x00\x01\xD8\x37\xDC"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_LE}); + auto uio = + u16::open(io::memory("\x24\x00\x01\xD8\x37\xDC"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_LE}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -59,12 +65,17 @@ TEST(uio_u16, sample_le) { } TEST(uio_u8, sample_detect) { - auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" "es")); + auto uio = + u8::open(io::memory("\xf0\x90\x8D\x85" + "es")); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); EXPECT_EQ(6, ret.value()); - EXPECT_EQ("\xf0\x90\x8D\x85" "es", tmp); + EXPECT_EQ( + "\xf0\x90\x8D\x85" + "es", + tmp); } TEST(uio_u16, sample_detect_be) { @@ -92,8 +103,8 @@ TEST(uio_u16, sample_detect_le) { TEST(uio_u8, invalid) { auto uio = u8::open(io::memory("r\xe4ksm\xf6rg\xe5s"), u::ReaderConfig{ - .strict=true, - .input=u::ReaderInputFormat::UTF8, + .strict = true, + .input = u::ReaderInputFormat::UTF8, }); std::string tmp; auto ret = uio->repeat_read(tmp, 20); @@ -107,7 +118,7 @@ TEST(uio_u8, invalid) { TEST(uio_u8, invalid_detect) { auto uio = u8::open(io::memory("r\xe4ksm\xf6rg\xe5s"), - u::ReaderConfig{.strict=true}); + u::ReaderConfig{.strict = true}); std::string tmp; auto ret = uio->repeat_read(tmp, 20); ASSERT_TRUE(ret.has_value()); @@ -121,8 +132,8 @@ TEST(uio_u8, invalid_detect) { TEST(uio_u8, invalid_replace) { auto uio = u8::open(io::memory("r\xe4ksm\xf6rg\xe5s"), u::ReaderConfig{ - .strict=false, - .input=u::ReaderInputFormat::UTF8, + .strict = false, + .input = u::ReaderInputFormat::UTF8, }); std::string tmp; auto ret = uio->repeat_read(tmp, 20); @@ -133,7 +144,7 @@ TEST(uio_u8, invalid_replace) { TEST(uio_u8, read_error) { auto uio = u8::open(io_make_breaking(io::memory("\xef\xbf\xbd"), 1), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF8}); + u::ReaderConfig{.input = u::ReaderInputFormat::UTF8}); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_FALSE(ret.has_value()); @@ -141,8 +152,9 @@ TEST(uio_u8, read_error) { } TEST(uio_u16, read_error) { - auto uio = u16::open(io_make_breaking(io::memory("\x00\x24"s), 1), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_BE}); + auto uio = + u16::open(io_make_breaking(io::memory("\x00\x24"s), 1), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_BE}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_FALSE(ret.has_value()); @@ -150,11 +162,10 @@ TEST(uio_u16, read_error) { } TEST(uio_u8, read_incomplete_strict) { - auto uio = u8::open(io::memory("\xef"), - u::ReaderConfig{ - .strict=true, - .input=u::ReaderInputFormat::UTF8, - }); + auto uio = u8::open(io::memory("\xef"), u::ReaderConfig{ + .strict = true, + .input = u::ReaderInputFormat::UTF8, + }); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_FALSE(ret.has_value()); @@ -162,11 +173,10 @@ TEST(uio_u8, read_incomplete_strict) { } TEST(uio_u8, read_incomplete) { - auto uio = u8::open(io::memory("\xef"), - u::ReaderConfig{ - .strict=false, - .input=u::ReaderInputFormat::UTF8, - }); + auto uio = u8::open(io::memory("\xef"), u::ReaderConfig{ + .strict = false, + .input = u::ReaderInputFormat::UTF8, + }); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -175,11 +185,11 @@ TEST(uio_u8, read_incomplete) { } TEST(uio_u16, read_incomplete_strict_be) { - auto uio = u16::open(io::memory("\x00"s), - u::ReaderConfig{ - .strict=true, - .input=u::ReaderInputFormat::UTF16_BE, - }); + auto uio = + u16::open(io::memory("\x00"s), u::ReaderConfig{ + .strict = true, + .input = u::ReaderInputFormat::UTF16_BE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_FALSE(ret.has_value()); @@ -187,11 +197,11 @@ TEST(uio_u16, read_incomplete_strict_be) { } TEST(uio_u16, read_incomplete_be) { - auto uio = u16::open(io::memory("\x00"s), - u::ReaderConfig{ - .strict=false, - .input=u::ReaderInputFormat::UTF16_BE, - }); + auto uio = + u16::open(io::memory("\x00"s), u::ReaderConfig{ + .strict = false, + .input = u::ReaderInputFormat::UTF16_BE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -200,11 +210,11 @@ TEST(uio_u16, read_incomplete_be) { } TEST(uio_u16, read_incomplete_strict_le) { - auto uio = u16::open(io::memory("$"), - u::ReaderConfig{ - .strict=true, - .input=u::ReaderInputFormat::UTF16_LE, - }); + auto uio = + u16::open(io::memory("$"), u::ReaderConfig{ + .strict = true, + .input = u::ReaderInputFormat::UTF16_LE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_FALSE(ret.has_value()); @@ -212,11 +222,11 @@ TEST(uio_u16, read_incomplete_strict_le) { } TEST(uio_u16, read_incomplete_le) { - auto uio = u16::open(io::memory("$"), - u::ReaderConfig{ - .strict=false, - .input=u::ReaderInputFormat::UTF16_LE, - }); + auto uio = + u16::open(io::memory("$"), u::ReaderConfig{ + .strict = false, + .input = u::ReaderInputFormat::UTF16_LE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -225,8 +235,9 @@ TEST(uio_u16, read_incomplete_le) { } TEST(uio_u8, max_too_small) { - auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" "es"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF8}); + auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" + "es"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF8}); std::string tmp; auto ret = uio->read(tmp.data(), 0); ASSERT_TRUE(ret.has_value()); @@ -238,8 +249,9 @@ TEST(uio_u8, max_too_small) { } TEST(uio_u16, max_too_small_be) { - auto uio = u16::open(io::memory("\xD8\x01\xDC\x37"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_BE}); + auto uio = + u16::open(io::memory("\xD8\x01\xDC\x37"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_BE}); std::u16string tmp; auto ret = uio->read(tmp.data(), 0); ASSERT_TRUE(ret.has_value()); @@ -251,8 +263,9 @@ TEST(uio_u16, max_too_small_be) { } TEST(uio_u16, max_too_small_le) { - auto uio = u16::open(io::memory("\x01\xD8\x37\xDC"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_LE}); + auto uio = + u16::open(io::memory("\x01\xD8\x37\xDC"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_LE}); std::u16string tmp; auto ret = uio->read(tmp.data(), 0); ASSERT_TRUE(ret.has_value()); @@ -264,8 +277,9 @@ TEST(uio_u16, max_too_small_le) { } TEST(uio_u8, partial) { - auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" "es"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF8}); + auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" + "es"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF8}); std::string tmp; auto ret = uio->repeat_read(tmp, 4); ASSERT_TRUE(ret.has_value()); @@ -279,8 +293,9 @@ TEST(uio_u8, partial) { } TEST(uio_u16, partial_be) { - auto uio = u16::open(io::memory("\x00\x24\xD8\x01\xDC\x37"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_BE}); + auto uio = + u16::open(io::memory("\x00\x24\xD8\x01\xDC\x37"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_BE}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 1); ASSERT_TRUE(ret.has_value()); @@ -295,8 +310,9 @@ TEST(uio_u16, partial_be) { } TEST(uio_u16, partial_le) { - auto uio = u16::open(io::memory("\x24\x00\x01\xD8\x37\xDC"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_LE}); + auto uio = + u16::open(io::memory("\x24\x00\x01\xD8\x37\xDC"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_LE}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 1); ASSERT_TRUE(ret.has_value()); @@ -312,10 +328,10 @@ TEST(uio_u16, partial_le) { TEST(uio_u16, invalid_be) { auto uio = u16::open(io::memory("\x00\x24\xd8\x01"s), - u::ReaderConfig{ - .strict=true, - .input=u::ReaderInputFormat::UTF16_BE, - }); + u::ReaderConfig{ + .strict = true, + .input = u::ReaderInputFormat::UTF16_BE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -328,7 +344,7 @@ TEST(uio_u16, invalid_be) { TEST(uio_u16, invalid_detect_be) { auto uio = u16::open(io::memory("\x00\x24\xd8\x01"s), - u::ReaderConfig{.strict=true}); + u::ReaderConfig{.strict = true}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -341,10 +357,10 @@ TEST(uio_u16, invalid_detect_be) { TEST(uio_u16, invalid_replace_be) { auto uio = u16::open(io::memory("\x00\x24\xd8\x01"s), - u::ReaderConfig{ - .strict=false, - .input=u::ReaderInputFormat::UTF16_BE, - }); + u::ReaderConfig{ + .strict = false, + .input = u::ReaderInputFormat::UTF16_BE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -355,10 +371,10 @@ TEST(uio_u16, invalid_replace_be) { TEST(uio_u16, invalid_le) { auto uio = u16::open(io::memory("\x24\x00\x01\xd8"s), - u::ReaderConfig{ - .strict=true, - .input=u::ReaderInputFormat::UTF16_LE, - }); + u::ReaderConfig{ + .strict = true, + .input = u::ReaderInputFormat::UTF16_LE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -371,7 +387,7 @@ TEST(uio_u16, invalid_le) { TEST(uio_u16, invalid_detect_le) { auto uio = u16::open(io::memory("\x24\x00\x01\xd8"s), - u::ReaderConfig{.strict=true}); + u::ReaderConfig{.strict = true}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -384,10 +400,10 @@ TEST(uio_u16, invalid_detect_le) { TEST(uio_u16, invalid_replace_le) { auto uio = u16::open(io::memory("\x24\x00\x01\xd8"s), - u::ReaderConfig{ - .strict=false, - .input=u::ReaderInputFormat::UTF16_LE, - }); + u::ReaderConfig{ + .strict = false, + .input = u::ReaderInputFormat::UTF16_LE, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -397,31 +413,40 @@ TEST(uio_u16, invalid_replace_le) { } TEST(uio_u8, bom) { - auto uio = u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" "es"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF8}); + auto uio = u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" + "es"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF8}); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); EXPECT_EQ(6, ret.value()); - EXPECT_EQ("\xf0\x90\x8D\x85" "es", tmp); + EXPECT_EQ( + "\xf0\x90\x8D\x85" + "es", + tmp); } TEST(uio_u8, bom_keep) { - auto uio = u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" "es"), + auto uio = u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" + "es"), u::ReaderConfig{ - .input=u::ReaderInputFormat::UTF8, - .skip_bom=false, + .input = u::ReaderInputFormat::UTF8, + .skip_bom = false, }); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); EXPECT_EQ(9, ret.value()); - EXPECT_EQ("\xef\xbb\xbf\xf0\x90\x8D\x85" "es", tmp); + EXPECT_EQ( + "\xef\xbb\xbf\xf0\x90\x8D\x85" + "es", + tmp); } TEST(uio_u16, bom_be) { - auto uio = u16::open(io::memory("\xfe\xff\x00\x24\xD8\x01\xDC\x37"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_BE}); + auto uio = + u16::open(io::memory("\xfe\xff\x00\x24\xD8\x01\xDC\x37"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_BE}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -432,8 +457,9 @@ TEST(uio_u16, bom_be) { } TEST(uio_u16, bom_le) { - auto uio = u16::open(io::memory("\xff\xfe\x24\x00\x01\xD8\x37\xDC"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_LE}); + auto uio = + u16::open(io::memory("\xff\xfe\x24\x00\x01\xD8\x37\xDC"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_LE}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -445,10 +471,10 @@ TEST(uio_u16, bom_le) { TEST(uio_u16, bom_keep_be) { auto uio = u16::open(io::memory("\xfe\xff\x00\x24\xD8\x01\xDC\x37"s), - u::ReaderConfig{ - .input=u::ReaderInputFormat::UTF16_BE, - .skip_bom=false, - }); + u::ReaderConfig{ + .input = u::ReaderInputFormat::UTF16_BE, + .skip_bom = false, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -461,10 +487,10 @@ TEST(uio_u16, bom_keep_be) { TEST(uio_u16, bom_keep_le) { auto uio = u16::open(io::memory("\xff\xfe\x24\x00\x01\xD8\x37\xDC"s), - u::ReaderConfig{ - .input=u::ReaderInputFormat::UTF16_LE, - .skip_bom=false, - }); + u::ReaderConfig{ + .input = u::ReaderInputFormat::UTF16_LE, + .skip_bom = false, + }); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -476,22 +502,31 @@ TEST(uio_u16, bom_keep_le) { } TEST(uio_u8, bom_detect) { - auto uio = u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" "es")); + auto uio = + u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" + "es")); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); EXPECT_EQ(6, ret.value()); - EXPECT_EQ("\xf0\x90\x8D\x85" "es", tmp); + EXPECT_EQ( + "\xf0\x90\x8D\x85" + "es", + tmp); } TEST(uio_u8, bom_keep_detect) { - auto uio = u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" "es"), - u::ReaderConfig{.skip_bom=false}); + auto uio = u8::open(io::memory("\xef\xbb\xbf\xf0\x90\x8D\x85" + "es"), + u::ReaderConfig{.skip_bom = false}); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); EXPECT_EQ(9, ret.value()); - EXPECT_EQ("\xef\xbb\xbf\xf0\x90\x8D\x85" "es", tmp); + EXPECT_EQ( + "\xef\xbb\xbf\xf0\x90\x8D\x85" + "es", + tmp); } TEST(uio_u16, bom_detect_be) { @@ -518,7 +553,7 @@ TEST(uio_u16, bom_detect_le) { TEST(uio_u16, bom_keep_detect_be) { auto uio = u16::open(io::memory("\xfe\xff\x00\x24\xD8\x01\xDC\x37"s), - u::ReaderConfig{.skip_bom=false}); + u::ReaderConfig{.skip_bom = false}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -531,7 +566,7 @@ TEST(uio_u16, bom_keep_detect_be) { TEST(uio_u16, bom_keep_detect_le) { auto uio = u16::open(io::memory("\xff\xfe\x24\x00\x01\xD8\x37\xDC"s), - u::ReaderConfig{.skip_bom=false}); + u::ReaderConfig{.skip_bom = false}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -544,7 +579,7 @@ TEST(uio_u16, bom_keep_detect_le) { TEST(uio_u8, input_utf16_be) { auto uio = u8::open(io::memory("\x00\x24\xD8\x01\xDC\x37"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_BE}); + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_BE}); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -554,7 +589,7 @@ TEST(uio_u8, input_utf16_be) { TEST(uio_u8, input_utf16_le) { auto uio = u8::open(io::memory("\x24\x00\x01\xD8\x37\xDC"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_LE}); + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_LE}); std::string tmp; auto ret = uio->repeat_read(tmp, 10); ASSERT_TRUE(ret.has_value()); @@ -563,8 +598,9 @@ TEST(uio_u8, input_utf16_le) { } TEST(uio_u16, input_utf8) { - auto uio = u16::open(io::memory("\xf0\x90\x8D\x85" "es"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF8}); + auto uio = u16::open(io::memory("\xf0\x90\x8D\x85" + "es"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF8}); std::u16string tmp; auto ret = uio->repeat_read(tmp, 5); ASSERT_TRUE(ret.has_value()); @@ -576,8 +612,9 @@ TEST(uio_u16, input_utf8) { } TEST(uio_u8, skip) { - auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" "es"), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF8}); + auto uio = u8::open(io::memory("\xf0\x90\x8D\x85" + "es"), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF8}); std::string tmp; auto ret = uio->repeat_skip(3); ASSERT_FALSE(ret.has_value()); @@ -592,8 +629,9 @@ TEST(uio_u8, skip) { } TEST(uio_u16, skip_be) { - auto uio = u16::open(io::memory("\x00\x24\xD8\x01\xDC\x37"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_BE}); + auto uio = + u16::open(io::memory("\x00\x24\xD8\x01\xDC\x37"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_BE}); std::u16string tmp; auto ret = uio->repeat_skip(4); // Note that this is in bytes ASSERT_TRUE(ret.has_value()); @@ -606,8 +644,9 @@ TEST(uio_u16, skip_be) { } TEST(uio_u16, skip_le) { - auto uio = u16::open(io::memory("\x24\x00\x01\xD8\x37\xDC"s), - u::ReaderConfig{.input=u::ReaderInputFormat::UTF16_LE}); + auto uio = + u16::open(io::memory("\x24\x00\x01\xD8\x37\xDC"s), + u::ReaderConfig{.input = u::ReaderInputFormat::UTF16_LE}); std::u16string tmp; auto ret = uio->repeat_skip(4); // Note that this is in bytes ASSERT_TRUE(ret.has_value()); |
