18 void TagsUtilTest::testGetTagsDelimiter_data ()
20 QTest::addColumn<QString> (
"separator");
21 QTest::addColumn<QString> (
"expected");
24 QTest::newRow (
"spaces around") <<
" / "_qs <<
"/"_qs;
25 QTest::newRow (
"bare") <<
"|"_qs <<
"|"_qs;
26 QTest::newRow (
"whitespace only") <<
" "_qs <<
" "_qs;
29 void TagsUtilTest::testGetTagsDelimiter ()
31 QFETCH (QString, separator);
32 QFETCH (QString, expected);
37 void TagsUtilTest::testSplitTags_data ()
39 QTest::addColumn<QString> (
"text");
40 QTest::addColumn<QString> (
"separator");
41 QTest::addColumn<QStringList> (
"expected");
43 const auto sep =
"; "_qs;
44 const auto a =
"a"_qs;
45 const auto b =
"b"_qs;
47 QTest::newRow (
"canonical") <<
"a; b"_qs << sep << QStringList { a, b };
48 QTest::newRow (
"single") << a << sep << QStringList { a };
49 QTest::newRow (
"empty") << QString {} << sep << QStringList {};
50 QTest::newRow (
"no space after separator") <<
"a;b"_qs << sep << QStringList { a, b };
51 QTest::newRow (
"whitespace around") <<
" a ; b "_qs << sep << QStringList { a, b };
52 QTest::newRow (
"empty parts") <<
"a;; ;b;"_qs << sep << QStringList { a, b };
53 QTest::newRow (
"whitespace inside kept") <<
"a b; c\td"_qs << sep << QStringList {
"a b"_qs,
"c\td"_qs };
54 QTest::newRow (
"whitespace separator") <<
"a b"_qs <<
" "_qs << QStringList { a, b };
55 QTest::newRow (
"any whitespace for a whitespace separator") <<
"a \t b"_qs <<
" "_qs << QStringList { a, b };
56 QTest::newRow (
"regex metachar separator") <<
"left|right"_qs <<
"|"_qs << QStringList {
"left"_qs,
"right"_qs };
59 void TagsUtilTest::testSplitTags ()
61 QFETCH (QString, text);
62 QFETCH (QString, separator);
63 QFETCH (QStringList, expected);
65 QCOMPARE (
SplitTags (text, separator), expected);
QStringList SplitTags(QStringView text, const QString &separator)
Splits a string with tags into the tags.
QString GetDefaultTagsSeparator()
QString GetTagsDelimiter(const QString &separator)
Returns the delimiter the tags are split by for the given separator they are joined with.