LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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 
13 QTEST_APPLESS_MAIN (LC::Util::TokenizeTest)
14 
15 namespace LC::Util
16 {
17  using QSVV = QList<QStringView>;
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 }
LC::Util::TokenizeTest
Definition: tokenizetest.h:21
QList
Definition: ianrulesstorage.h:14
LC::Util
Definition: icoreproxy.h:33
tokenizetest.h
tokenize.h
LC::Util::TokenizeRev
auto TokenizeRev(QStringView str)
Definition: tokenizetest.cpp:65
LC::Util::Reversed
auto Reversed(auto container)
Definition: tokenizetest.cpp:75
LC::Util::QSVV
QList< QStringView > QSVV
Definition: tokenizetest.cpp:23
LC::Util::TokenizeFwd
auto TokenizeFwd(QStringView str)
Definition: tokenizetest.cpp:25