mirror of
https://github.com/fmtlib/fmt.git
synced 2026-05-05 03:54:10 +02:00
Add UTF-8 types
This commit is contained in:
@@ -118,9 +118,13 @@ TEST(FormatTest, FormatErrorCode) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(FormatTest, CountCodePoints) {
|
||||
EXPECT_EQ(4, fmt::internal::count_code_points(fmt::u8string_view("ёжик")));
|
||||
}
|
||||
|
||||
TEST(ColorsTest, Colors) {
|
||||
EXPECT_WRITE(stdout, fmt::print(fmt::rgb(255,20,30), "rgb(255,20,30)"),
|
||||
"\x1b[38;2;255;020;030mrgb(255,20,30)\x1b[0m");
|
||||
EXPECT_WRITE(stdout, fmt::print(fmt::color::blue,"blue"),
|
||||
EXPECT_WRITE(stdout, fmt::print(fmt::color::blue, "blue"),
|
||||
"\x1b[38;2;000;000;255mblue\x1b[0m");
|
||||
}
|
||||
|
||||
@@ -1932,3 +1932,30 @@ TEST(FormatTest, FormatStringErrors) {
|
||||
}
|
||||
#endif // FMT_USE_CONSTEXPR
|
||||
|
||||
TEST(FormatTest, ConstructU8StringViewFromCString) {
|
||||
fmt::u8string_view s("ab");
|
||||
EXPECT_EQ(s.size(), 2u);
|
||||
const fmt::char8_t *data = s.data();
|
||||
EXPECT_EQ(data[0].value, 'a');
|
||||
EXPECT_EQ(data[1].value, 'b');
|
||||
}
|
||||
|
||||
TEST(FormatTest, ConstructU8StringViewFromDataAndSize) {
|
||||
fmt::u8string_view s("foobar", 3);
|
||||
EXPECT_EQ(s.size(), 3u);
|
||||
const fmt::char8_t *data = s.data();
|
||||
EXPECT_EQ(data[0].value, 'f');
|
||||
EXPECT_EQ(data[1].value, 'o');
|
||||
EXPECT_EQ(data[2].value, 'o');
|
||||
}
|
||||
|
||||
#if FMT_USE_USER_DEFINED_LITERALS
|
||||
TEST(FormatTest, U8StringViewLiteral) {
|
||||
using namespace fmt::literals;
|
||||
fmt::u8string_view s = "ab"_u;
|
||||
EXPECT_EQ(s.size(), 2u);
|
||||
const fmt::char8_t *data = s.data();
|
||||
EXPECT_EQ(data[0].value, 'a');
|
||||
EXPECT_EQ(data[1].value, 'b');
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-1
@@ -868,7 +868,8 @@ TEST(UtilTest, IsEnumConvertibleToInt) {
|
||||
#endif
|
||||
|
||||
TEST(UtilTest, ParseNonnegativeInt) {
|
||||
if (std::numeric_limits<int>::max() != static_cast<int>(static_cast<unsigned>(1) << 31)) {
|
||||
if (std::numeric_limits<int>::max() !=
|
||||
static_cast<int>(static_cast<unsigned>(1) << 31)) {
|
||||
fmt::print("Skipping parse_nonnegative_int test\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user