summaryrefslogtreecommitdiff
path: root/test/test_format.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-29 23:16:46 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-29 23:16:46 -0500
commit8dcb1de91e15ff7fc66279cd9cd9ad8a70f624e0 (patch)
treec73840b15a074cf37f59bc3b2eff56cde982d74f /test/test_format.cpp
parent8ce397e8c0a83e49e390de9deb73d588e4931ecf (diff)
u8 string literals
Diffstat (limited to 'test/test_format.cpp')
-rw-r--r--test/test_format.cpp196
1 files changed, 98 insertions, 98 deletions
diff --git a/test/test_format.cpp b/test/test_format.cpp
index 4dec6b1..b9d373c 100644
--- a/test/test_format.cpp
+++ b/test/test_format.cpp
@@ -27,20 +27,20 @@ TEST(FormatTest, BasePositionalTest)
{
size_t length = 0;
- auto formatSpecResult = FormatSpec::parse(StringView{" {1:}"}, length);
+ auto formatSpecResult = FormatSpec::parse(StringView{u8" {1:}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.takeError(), FudStatus::ArgumentInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{1}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
auto formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(formatSpec.position, 1);
EXPECT_EQ(length, 3);
- formatSpecResult = FormatSpec::parse(StringView{""}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8""}, length);
ASSERT_EQ(formatSpecResult.takeErrorOr(FudStatus::NotImplemented), FudStatus::ArgumentInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{1:}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 4);
@@ -60,7 +60,7 @@ TEST(FormatTest, AlignTest)
{
size_t length = 0;
- auto formatSpecResult = FormatSpec::parse(StringView{"{1:<}"}, length);
+ auto formatSpecResult = FormatSpec::parse(StringView{u8"{1:<}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
auto formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(formatSpec.position, 1);
@@ -74,14 +74,14 @@ TEST(FormatTest, AlignTest)
EXPECT_FALSE(formatSpec.hasLocale);
EXPECT_EQ(formatSpec.formatType, FormatType::Unspecified);
- formatSpecResult = FormatSpec::parse(StringView{"{1:<<}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:<<}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(formatSpec.position, 1);
EXPECT_EQ(formatSpec.fill.align(), FormatAlign::Value::Left);
EXPECT_EQ(formatSpec.fill.fill, '<');
- formatSpecResult = FormatSpec::parse(StringView{"{:<<}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:<<}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 5);
@@ -89,7 +89,7 @@ TEST(FormatTest, AlignTest)
EXPECT_EQ(formatSpec.fill.align(), FormatAlign::Value::Left);
EXPECT_EQ(formatSpec.fill.fill, '<');
- formatSpecResult = FormatSpec::parse(StringView{"{1:_<}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:_<}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 6);
@@ -102,7 +102,7 @@ TEST(FormatTest, SpecialTest)
{
size_t length = 0;
- auto formatSpecResult = FormatSpec::parse(StringView{"{1:_< }"}, length);
+ auto formatSpecResult = FormatSpec::parse(StringView{u8"{1:_< }"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
auto formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 7);
@@ -113,7 +113,7 @@ TEST(FormatTest, SpecialTest)
EXPECT_FALSE(formatSpec.alternateForm);
EXPECT_FALSE(formatSpec.leadingZero);
- formatSpecResult = FormatSpec::parse(StringView{"{1:+}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:+}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
EXPECT_EQ(length, 5);
formatSpec = formatSpecResult.takeOkay();
@@ -122,7 +122,7 @@ TEST(FormatTest, SpecialTest)
EXPECT_FALSE(formatSpec.alternateForm);
EXPECT_FALSE(formatSpec.leadingZero);
- formatSpecResult = FormatSpec::parse(StringView{"{1:-}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:-}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 5);
@@ -131,7 +131,7 @@ TEST(FormatTest, SpecialTest)
EXPECT_FALSE(formatSpec.alternateForm);
EXPECT_FALSE(formatSpec.leadingZero);
- formatSpecResult = FormatSpec::parse(StringView{"{1:_<#}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:_<#}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 7);
@@ -142,7 +142,7 @@ TEST(FormatTest, SpecialTest)
EXPECT_TRUE(formatSpec.alternateForm);
EXPECT_FALSE(formatSpec.leadingZero);
- formatSpecResult = FormatSpec::parse(StringView{"{1:_<0}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:_<0}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 7);
@@ -153,7 +153,7 @@ TEST(FormatTest, SpecialTest)
EXPECT_FALSE(formatSpec.alternateForm);
EXPECT_TRUE(formatSpec.leadingZero);
- formatSpecResult = FormatSpec::parse(StringView{"{1: #}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1: #}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 6);
@@ -164,15 +164,15 @@ TEST(FormatTest, SpecialTest)
EXPECT_TRUE(formatSpec.alternateForm);
EXPECT_FALSE(formatSpec.leadingZero);
- formatSpecResult = FormatSpec::parse(StringView{"{1:# }"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:# }"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.takeError(), FudStatus::FormatInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{1:##}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:##}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.takeError(), FudStatus::FormatInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{1: 0}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1: 0}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 6);
@@ -183,19 +183,19 @@ TEST(FormatTest, SpecialTest)
EXPECT_FALSE(formatSpec.alternateForm);
EXPECT_TRUE(formatSpec.leadingZero);
- formatSpecResult = FormatSpec::parse(StringView{"{1:0 }"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:0 }"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.takeError(), FudStatus::FormatInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{1:0#}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:0#}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.takeError(), FudStatus::FormatInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{1:#00}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:#00}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.takeError(), FudStatus::FormatInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{1: #0}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1: #0}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 7);
@@ -211,7 +211,7 @@ TEST(FormatTest, WidthTest)
{
size_t length = 0;
- auto formatSpecResult = FormatSpec::parse(StringView{"{1:1}"}, length);
+ auto formatSpecResult = FormatSpec::parse(StringView{u8"{1:1}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
auto formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 5);
@@ -219,7 +219,7 @@ TEST(FormatTest, WidthTest)
EXPECT_FALSE(formatSpec.takesWidth);
EXPECT_EQ(formatSpec.width, 1);
- formatSpecResult = FormatSpec::parse(StringView{"{1:543}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:543}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 7);
@@ -227,7 +227,7 @@ TEST(FormatTest, WidthTest)
EXPECT_FALSE(formatSpec.takesWidth);
EXPECT_EQ(formatSpec.width, 543);
- formatSpecResult = FormatSpec::parse(StringView{"{:543}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:543}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 6);
@@ -236,16 +236,16 @@ TEST(FormatTest, WidthTest)
EXPECT_EQ(formatSpec.width, 543);
// leading zero
- formatSpecResult = FormatSpec::parse(StringView{"{1:00}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:00}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::FormatInvalid);
// #x100000000 4294967296
- formatSpecResult = FormatSpec::parse(StringView{"{1:4294967296}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:4294967296}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::RangeError);
- formatSpecResult = FormatSpec::parse(StringView{"{1:{1}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:{1}}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 7);
@@ -254,15 +254,15 @@ TEST(FormatTest, WidthTest)
EXPECT_EQ(formatSpec.width, 1);
// #x10000 65536
- formatSpecResult = FormatSpec::parse(StringView{"{1:{65536}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:{65536}}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::RangeError);
- formatSpecResult = FormatSpec::parse(StringView{"{:{1}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:{1}}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::FormatInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{:{}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:{}}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 5);
@@ -275,7 +275,7 @@ TEST(FormatTest, PrecisionTest)
{
size_t length = 0;
- auto formatSpecResult = FormatSpec::parse(StringView{"{1:.1}"}, length);
+ auto formatSpecResult = FormatSpec::parse(StringView{u8"{1:.1}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
auto formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 6);
@@ -283,7 +283,7 @@ TEST(FormatTest, PrecisionTest)
EXPECT_FALSE(formatSpec.takesPrecision);
EXPECT_EQ(formatSpec.precision, 1);
- formatSpecResult = FormatSpec::parse(StringView{"{1:.543}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:.543}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 8);
@@ -291,7 +291,7 @@ TEST(FormatTest, PrecisionTest)
EXPECT_FALSE(formatSpec.takesPrecision);
EXPECT_EQ(formatSpec.precision, 543);
- formatSpecResult = FormatSpec::parse(StringView{"{:.543}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:.543}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 7);
@@ -300,16 +300,16 @@ TEST(FormatTest, PrecisionTest)
EXPECT_EQ(formatSpec.precision, 543);
// leading zero
- formatSpecResult = FormatSpec::parse(StringView{"{1:00}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:00}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::FormatInvalid);
// #x100000000 4294967296
- formatSpecResult = FormatSpec::parse(StringView{"{1:.4294967296}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:.4294967296}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::RangeError);
- formatSpecResult = FormatSpec::parse(StringView{"{1:.{1}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:.{1}}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 8);
@@ -318,15 +318,15 @@ TEST(FormatTest, PrecisionTest)
EXPECT_EQ(formatSpec.precision, 1);
// #x10000 65536
- formatSpecResult = FormatSpec::parse(StringView{"{1:.{65536}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{1:.{65536}}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::RangeError);
- formatSpecResult = FormatSpec::parse(StringView{"{:.{1}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:.{1}}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.getError(), FudStatus::FormatInvalid);
- formatSpecResult = FormatSpec::parse(StringView{"{:.{}}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:.{}}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 6);
@@ -339,14 +339,14 @@ TEST(FormatTest, LocaleTest)
{
size_t length = 0;
- auto formatSpecResult = FormatSpec::parse(StringView{"{1:L}"}, length);
+ auto formatSpecResult = FormatSpec::parse(StringView{u8"{1:L}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
auto formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 5);
EXPECT_EQ(formatSpec.position, 1);
EXPECT_TRUE(formatSpec.hasLocale);
- formatSpecResult = FormatSpec::parse(StringView{"{:L}"}, length);
+ formatSpecResult = FormatSpec::parse(StringView{u8"{:L}"}, length);
ASSERT_TRUE(formatSpecResult.isOkay());
formatSpec = formatSpecResult.takeOkay();
EXPECT_EQ(length, 4);
@@ -358,23 +358,23 @@ TEST(FormatTest, FormatTest)
{
auto lengthArray{Array<size_t, 17>::constFill(0U)};
const Array<FormatSpecResult, 17> formatTypeResults{
- FormatSpec::parse(StringView{"{:s}"}, lengthArray[0x00]),
- FormatSpec::parse(StringView{"{:?}"}, lengthArray[0x01]),
- FormatSpec::parse(StringView{"{:b}"}, lengthArray[0x02]),
- FormatSpec::parse(StringView{"{:B}"}, lengthArray[0x03]),
- FormatSpec::parse(StringView{"{:c}"}, lengthArray[0x04]),
- FormatSpec::parse(StringView{"{:d}"}, lengthArray[0x05]),
- FormatSpec::parse(StringView{"{:o}"}, lengthArray[0x06]),
- FormatSpec::parse(StringView{"{:x}"}, lengthArray[0x07]),
- FormatSpec::parse(StringView{"{:X}"}, lengthArray[0x08]),
- FormatSpec::parse(StringView{"{:a}"}, lengthArray[0x09]),
- FormatSpec::parse(StringView{"{:A}"}, lengthArray[0x0A]),
- FormatSpec::parse(StringView{"{:e}"}, lengthArray[0x0B]),
- FormatSpec::parse(StringView{"{:E}"}, lengthArray[0x0C]),
- FormatSpec::parse(StringView{"{:f}"}, lengthArray[0x0D]),
- FormatSpec::parse(StringView{"{:F}"}, lengthArray[0x0E]),
- FormatSpec::parse(StringView{"{:g}"}, lengthArray[0x0F]),
- FormatSpec::parse(StringView{"{:G}"}, lengthArray[0x10])};
+ FormatSpec::parse(StringView{u8"{:s}"}, lengthArray[0x00]),
+ FormatSpec::parse(StringView{u8"{:?}"}, lengthArray[0x01]),
+ FormatSpec::parse(StringView{u8"{:b}"}, lengthArray[0x02]),
+ FormatSpec::parse(StringView{u8"{:B}"}, lengthArray[0x03]),
+ FormatSpec::parse(StringView{u8"{:c}"}, lengthArray[0x04]),
+ FormatSpec::parse(StringView{u8"{:d}"}, lengthArray[0x05]),
+ FormatSpec::parse(StringView{u8"{:o}"}, lengthArray[0x06]),
+ FormatSpec::parse(StringView{u8"{:x}"}, lengthArray[0x07]),
+ FormatSpec::parse(StringView{u8"{:X}"}, lengthArray[0x08]),
+ FormatSpec::parse(StringView{u8"{:a}"}, lengthArray[0x09]),
+ FormatSpec::parse(StringView{u8"{:A}"}, lengthArray[0x0A]),
+ FormatSpec::parse(StringView{u8"{:e}"}, lengthArray[0x0B]),
+ FormatSpec::parse(StringView{u8"{:E}"}, lengthArray[0x0C]),
+ FormatSpec::parse(StringView{u8"{:f}"}, lengthArray[0x0D]),
+ FormatSpec::parse(StringView{u8"{:F}"}, lengthArray[0x0E]),
+ FormatSpec::parse(StringView{u8"{:g}"}, lengthArray[0x0F]),
+ FormatSpec::parse(StringView{u8"{:G}"}, lengthArray[0x10])};
const Array<FormatType, 17> formatTypes{
FormatType::String,
FormatType::Escaped,
@@ -406,7 +406,7 @@ TEST(FormatTest, FormatTest)
size_t length = 0;
- auto formatSpecResult = FormatSpec::parse(StringView{"{:N}"}, length);
+ auto formatSpecResult = FormatSpec::parse(StringView{u8"{:N}"}, length);
ASSERT_TRUE(formatSpecResult.isError());
EXPECT_EQ(formatSpecResult.takeError(), FudStatus::FormatInvalid);
}
@@ -415,13 +415,13 @@ TEST(FormatTest, NoArgFormatTest)
{
String sink{};
auto expected = std::format("Test");
- auto formatResult = format(sink, FormatCharMode::Unchecked, "Test");
+ auto formatResult = format(sink, FormatCharMode::Unchecked, u8"Test");
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("");
- formatResult = format(sink, FormatCharMode::Unchecked, "");
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"");
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
}
@@ -429,66 +429,66 @@ TEST(FormatTest, NoArgFormatTest)
TEST(FormatTest, OneNumberFormatTest)
{
String sink{};
- auto formatResult = format(sink, FormatCharMode::Unchecked, "Test {:}", 42U);
+ auto formatResult = format(sink, FormatCharMode::Unchecked, u8"Test {:}", 42U);
EXPECT_TRUE(formatResult.isOkay());
ASSERT_EQ(sink.clear(), FudStatus::Success);
auto expected = std::format("{:6}", 42U);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:6}", 42U);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:6}", 42U);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:*<6}", std::numeric_limits<uint64_t>::max());
- formatResult = format(sink, FormatCharMode::Unchecked, "{:*<6}", std::numeric_limits<uint64_t>::max());
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:*<6}", std::numeric_limits<uint64_t>::max());
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:*<6}", std::numeric_limits<int64_t>::min());
- formatResult = format(sink, FormatCharMode::Unchecked, "{:*<6}", std::numeric_limits<int64_t>::min());
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:*<6}", std::numeric_limits<int64_t>::min());
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:}", std::numeric_limits<int8_t>::min());
- formatResult = format(sink, FormatCharMode::Unchecked, "{:}", std::numeric_limits<int8_t>::min());
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:}", std::numeric_limits<int8_t>::min());
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:#X}", std::numeric_limits<int8_t>::min());
- formatResult = format(sink, FormatCharMode::Unchecked, "{:#X}", std::numeric_limits<int8_t>::min());
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:#X}", std::numeric_limits<int8_t>::min());
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:*<6}", 42U);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:*<6}", 42U);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:*<6}", 42U);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:*>6}", 42U);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:*>6}", 42U);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:*>6}", 42U);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:*^6}", 42U);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:*^6}", 42U);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:*^6}", 42U);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:*<6}", 'x');
- formatResult = format(sink, FormatCharMode::Unchecked, "{:*<6}", 'x');
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:*<6}", 'x');
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:6d}", 'x');
- formatResult = format(sink, FormatCharMode::Unchecked, "{:6d}", 'x');
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:6d}", 'x');
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
}
@@ -499,7 +499,7 @@ TEST(FormatTest, OneBoolFormatTest)
ASSERT_EQ(sink.clear(), FudStatus::Success);
auto expected = std::format("{:6}", true);
- auto formatResult = format(sink, FormatCharMode::Unchecked, "{:6}", true);
+ auto formatResult = format(sink, FormatCharMode::Unchecked, u8"{:6}", true);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
}
@@ -511,13 +511,13 @@ TEST(FormatTest, OneFloatFormatUnspecifiedTest)
ASSERT_EQ(sink.clear(), FudStatus::Success);
auto expected = std::format("{:}", 42.0);
- auto formatResult = format(sink, FormatCharMode::Unchecked, "{:}", 42.0);
+ auto formatResult = format(sink, FormatCharMode::Unchecked, u8"{:}", 42.0);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("{:1.0}", 42.0);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.0}", 42.0);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.0}", 42.0);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.0}", 42.0);
@@ -535,73 +535,73 @@ TEST(FormatTest, OneFloatFormatScientificTest)
ASSERT_EQ(sink.clear(), FudStatus::Success);
auto expected = std::format("{:e}", 42.0);
- auto formatResult = format(sink, FormatCharMode::Unchecked, "{:e}", 42.0);
+ auto formatResult = format(sink, FormatCharMode::Unchecked, u8"{:e}", 42.0);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.2e}", 0.99);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.2e}", 0.99);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.2e}", 0.99);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.1e}", 0.99);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.1e}", 0.99);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.1e}", 0.99);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.0e}", 0.99);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.0e}", 0.99);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.0e}", 0.99);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.0e}", -0.99);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.0e}", -0.99);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.0e}", -0.99);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.0e}", 42.0);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.0e}", 42.0);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.0e}", 42.0);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.0e}", 4.20e-5);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.0e}", 4.20e-5);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.0e}", 4.20e-5);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("{:1.0e}", -4.20e-5);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "{:1.0e}", -4.20e-5);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"{:1.0e}", -4.20e-5);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("e {:e}", 3.14);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:e}", 3.14);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:e}", 3.14);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("E {:E}", 3.14);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "E {:E}", 3.14);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"E {:E}", 3.14);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("e {:.0e}", 3.14);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:.0e}", 3.14);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:.0e}", 3.14);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("e {:+#010.0e}", 3.14);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:+#010.0e}", 3.14);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:+#010.0e}", 3.14);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
@@ -610,31 +610,31 @@ TEST(FormatTest, OneFloatFormatScientificTest)
expected = std::format("e {:.0e}", maxVal / 4);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:.0e}", maxVal / 4);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:.0e}", maxVal / 4);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("e {:.0e}", maxVal / 2);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:.0e}", maxVal / 2);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:.0e}", maxVal / 2);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("e {:.0e}", maxVal);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:.0e}", maxVal);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:.0e}", maxVal);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("e {:.0e}", std::numeric_limits<double>::min());
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:.0e}", std::numeric_limits<double>::min());
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:.0e}", std::numeric_limits<double>::min());
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("e {:.0e}", subNormMin);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "e {:.0e}", subNormMin);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"e {:.0e}", subNormMin);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
@@ -642,7 +642,7 @@ TEST(FormatTest, OneFloatFormatScientificTest)
expected = std::format("E#+ {:+#060.50E}", val);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "E#+ {:+#060.50E}", val);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"E#+ {:+#060.50E}", val);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
// Which is: "E#+ +0003.0000000000000000000000000000000000E+00"
@@ -651,19 +651,19 @@ TEST(FormatTest, OneFloatFormatScientificTest)
/*
expected = std::format("E#+ {:Z>+#060.30E}", val);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "E#+ {:Z>+#060.30E}", val);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"E#+ {:Z>+#060.30E}", val);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("E#+ {:Z<+#060.30E}", val);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "E#+ {:Z<+#060.30E}", val);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"E#+ {:Z<+#060.30E}", val);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
expected = std::format("E#+ {:Z^+#060.30E}", val);
ASSERT_EQ(sink.clear(), FudStatus::Success);
- formatResult = format(sink, FormatCharMode::Unchecked, "E#+ {:Z^+#060.30E}", val);
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"E#+ {:Z^+#060.30E}", val);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
*/
@@ -698,13 +698,13 @@ TEST(FormatTest, TwoArgFormatTest)
{
String sink{};
auto expected = std::format("Test {:} {:}", 1U, false);
- auto formatResult = format(sink, FormatCharMode::Unchecked, "Test {:} {:}", 1U, false);
+ auto formatResult = format(sink, FormatCharMode::Unchecked, u8"Test {:} {:}", 1U, false);
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
ASSERT_EQ(sink.clear(), FudStatus::Success);
expected = std::format("Test {:} {:}", 1U, "Hello");
- formatResult = format(sink, FormatCharMode::Unchecked, "Test {:} {:}", 1U, "Hello");
+ formatResult = format(sink, FormatCharMode::Unchecked, u8"Test {:} {:}", 1U, u8"Hello");
EXPECT_TRUE(formatResult.isOkay());
EXPECT_STREQ(sink.c_str(), expected.c_str());
}