LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
qtutiltest.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 "qtutiltest.h"
10#include <QtTest>
11#include <qtutil.h>
12
13QTEST_APPLESS_MAIN (LC::Util::QtUtilTest)
14
15namespace LC::Util
16{
17 void QtUtilTest::testStringUDL ()
18 {
19 const auto& foo1 = "foo"_qs;
20 const auto& bar = "bar"_qs;
21 QCOMPARE (foo1, "foo");
22 QCOMPARE (bar, "bar");
23
24 auto foo2 = "foo"_qs;
25 QCOMPARE (foo2, "foo");
26
27 foo2.chop (1);
28 QCOMPARE (foo2, "fo");
29 QCOMPARE (foo1, "foo");
30 }
31
32 void QtUtilTest::testStringUDLBench ()
33 {
34 QFETCH (int, strInit);
35
36 switch (strInit)
37 {
38 case 0:
39 QBENCHMARK
40 {
41 const QString str { "foo" };
42 }
43 break;
44 case 1:
45 QBENCHMARK
46 {
47 const auto str = QStringLiteral ("foo");
48 }
49 break;
50 case 2:
51 QBENCHMARK
52 {
53 const auto str = "foo"_qs;
54 }
55 break;
56 }
57 }
58
59 void QtUtilTest::testStringUDLBench_data ()
60 {
61 QTest::addColumn<int> ("strInit");
62 QTest::newRow ("ctor") << 0;
63 QTest::newRow ("QStringLiteral") << 1;
64 QTest::newRow ("UDL") << 2;
65 }
66}
67