LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
ctstringtest.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "ctstringtest.h"
10#include <QtTest>
11#include <ctstring.h>
12#include <ctstringutils.h>
13
14QTEST_APPLESS_MAIN (LC::Util::CtStringTest)
15
16namespace LC::Util
17{
18#define TEST_STR "test string"
19 void CtStringTest::testConstruction ()
20 {
21 constexpr CtString s { TEST_STR };
23 }
24
25 void CtStringTest::testUnsizedConstruction ()
26 {
27 constexpr auto getStr = [] () constexpr { return TEST_STR; };
28
29 constexpr auto s = CtString<StringBufSize (getStr ())>::FromUnsized (getStr ());
31 }
32
33 void CtStringTest::testUDL ()
34 {
35 constexpr auto s = "test string"_ct;
37 }
38
39 void CtStringTest::testConcat ()
40 {
41 constexpr auto s1 = "hello, "_ct;
42 constexpr auto s2 = "world!"_ct;
43 constexpr auto s3 = " how's life?"_ct;
44
45 constexpr auto concat = s1 + s2 + s3;
46 const QString expected { "hello, world! how's life?" };
48
49 constexpr auto concat2 = "hello, "_ct;
50 QCOMPARE (ToString<concat2 + "world!" + " how's life?"> (), expected);
51 }
52
53 void CtStringTest::testNub ()
54 {
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 };
57
58 constexpr static auto F = [&] { return input; };
59 constexpr auto nubbed = Nub<F>();
60 static_assert (nubbed == expected);
61 }
62}
#define TEST_STR
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
QString ToString()
Definition ctstring.h:130
constexpr size_t StringBufSize(const Char *str) noexcept
Definition ctstring.h:151
CtString(RawStr< N, Char >) -> CtString< N - 1, Char >