18 #define TEST_STR "test string" 19 void CtStringTest::testConstruction ()
22 QCOMPARE (ToString<s> (), QString {
TEST_STR });
25 void CtStringTest::testUnsizedConstruction ()
27 constexpr
auto getStr = [] () constexpr {
return TEST_STR; };
30 QCOMPARE (ToString<s> (), QString {
TEST_STR });
33 void CtStringTest::testUDL ()
35 constexpr
auto s =
"test string"_ct;
36 QCOMPARE (ToString<s> (), QString {
TEST_STR });
39 void CtStringTest::testConcat ()
41 constexpr
auto s1 =
"hello, "_ct;
42 constexpr
auto s2 =
"world!"_ct;
43 constexpr
auto s3 =
" how's life?"_ct;
45 constexpr
auto concat = s1 + s2 + s3;
46 const QString expected {
"hello, world! how's life?" };
47 QCOMPARE (ToString<concat> (), expected);
49 QCOMPARE (ToString<"hello, "_ct + "world!" + " how's life?"> (), expected);
51 QCOMPARE (ToString<"hello, " + "world!"_ct + " how's life?"> (), expected);
54 void CtStringTest::testReplaceAll ()
56 constexpr
auto s1 =
"Hello, _! The _ is nice!"_ct;
57 constexpr
auto s2 =
"world"_ct;
58 constexpr
auto s3 = ReplaceAll<s1, '_'> (s2);
59 QCOMPARE (ToString<s3> (),
"Hello, world! The world is nice!");
62 void CtStringTest::testNub ()
64 constexpr
static std::tuple input {
"hello"_ct,
"world"_ct,
"hello"_ct,
"lc"_ct,
"what's"_ct,
"up"_ct,
"lc"_ct,
"lc"_ct };
65 constexpr
std::tuple expected {
"hello"_ct,
"world"_ct,
"lc"_ct,
"what's"_ct,
"up"_ct };
67 constexpr
static auto F = [&] {
return input; };
68 constexpr
auto nubbed = Nub<F>();
69 static_assert (nubbed == expected);
74 [[maybe_unused]] constexpr
auto str =
"hello, " +
"world!"_ct +
" how's life?";
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptrs... > > tuple
CtString(RawStr< N, Char >) -> CtString< N - 1, Char >
static constexpr auto FromUnsized(const Char *s) noexcept