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 constexpr
auto concat2 =
"hello, "_ct;
50 QCOMPARE (ToString<concat2 + "world!" + " how's life?"> (), expected);
53 void CtStringTest::testNub ()
55 constexpr
static std::tuple input {
"hello"_ct,
"world"_ct,
"hello"_ct,
"lc"_ct,
"what's"_ct,
"up"_ct,
"lc"_ct,
"lc"_ct };
56 constexpr std::tuple expected {
"hello"_ct,
"world"_ct,
"lc"_ct,
"what's"_ct,
"up"_ct };
58 constexpr
static auto F = [&] {
return input; };
59 constexpr
auto nubbed = Nub<F>();
60 static_assert (nubbed == expected);
CtString(RawStr< N, Char >) -> CtString< N - 1, Char >
static constexpr auto FromUnsized(const Char *s) noexcept