LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
tokenizetest.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 "tokenizetest.h"
10#include <QtTest>
11#include <tokenize.h>
12
13QTEST_APPLESS_MAIN (LC::Util::TokenizeTest)
14
15namespace LC::Util
16{
18
19 auto TokenizeFwd (QStringView str)
20 {
21 Tokenize t { str, '.' };
22 QSVV tokenized { t.begin (), t.end () };
23 QCOMPARE (tokenized, str.split ('.'));
24 }
25
26 void TokenizeTest::testForwardEmpty ()
27 {
28 // not ideal, but it simplifies the implementation a lot
29 TokenizeFwd ({});
30 }
31
32 void TokenizeTest::testForwardSimple ()
33 {
34 TokenizeFwd (u"some.test.string");
35 }
36
37 void TokenizeTest::testForwardWithEmpty ()
38 {
39 TokenizeFwd (u"some..test.string");
40 }
41
42 void TokenizeTest::testForwardStartSep ()
43 {
44 TokenizeFwd (u"...some..test.string");
45 }
46
47 void TokenizeTest::testForwardEndSep ()
48 {
49 TokenizeFwd (u"some..test.string..");
50 }
51
52 void TokenizeTest::testForwardJustSeps ()
53 {
54 TokenizeFwd (u".");
55 TokenizeFwd (u"..");
56 }
57
58
59 auto TokenizeRev (QStringView str)
60 {
61 Tokenize t { str, '.' };
62 QSVV tokenized { t.rbegin (), t.rend () };
63
64 auto reference = str.split ('.');
65 std::reverse (reference.begin (), reference.end ());
66 QCOMPARE (tokenized, reference);
67 }
68
69 auto Reversed (auto container)
70 {
71 std::reverse (container.begin (), container.end ());
72 return container;
73 }
74
75 void TokenizeTest::testReverseEmpty ()
76 {
77 TokenizeRev ({});
78 }
79
80 void TokenizeTest::testReverseSimple ()
81 {
82 TokenizeRev (u"some.test.string");
83 }
84
85 void TokenizeTest::testReverseWithEmpty ()
86 {
87 TokenizeRev (u"some..test.string");
88 }
89
90 void TokenizeTest::testReverseStartSep ()
91 {
92 TokenizeRev (u"...some..test.string");
93 }
94
95 void TokenizeTest::testReverseEndSep ()
96 {
97 TokenizeRev (u"some..test.string..");
98 }
99
100 void TokenizeTest::testReverseJustSeps ()
101 {
102 TokenizeRev (u".");
103 TokenizeRev (u"..");
104 }
105}
QList< QStringView > QSVV
auto TokenizeRev(QStringView str)
auto Reversed(auto container)
auto TokenizeFwd(QStringView str)