LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
domchildrenrangetest.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 "
domchildrenrangetest.h
"
10
#include <QDomDocument>
11
#include <QString>
12
#include <QtTest>
13
#include <
domchildrenrange.h
>
14
15
QTEST_MAIN (
LC::Util::DomChildrenRangeTest
)
16
17
namespace
LC
18
{
19
namespace
Util
20
{
21
namespace
22
{
23
auto
MakeDocument (
const
QString& str)
24
{
25
QDomDocument doc;
26
doc.setContent (str);
27
return
doc.firstChildElement (
"root"
);
28
}
29
}
30
31
void
DomChildrenRangeTest::testEmpty ()
32
{
33
const
auto
& parent = MakeDocument (R
"(
34
<root>
35
</root>
36
)");
37
38
QStringList texts;
39
for
(
const
auto
& elem :
DomChildren
(parent,
"child"
))
40
texts << elem.text ();
41
QCOMPARE (texts, QStringList {});
42
}
43
44
void
DomChildrenRangeTest::testSingle ()
45
{
46
const
auto
& parent = MakeDocument (R
"(
47
<root>
48
<child>foo</child>
49
</root>
50
)");
51
52
QStringList texts;
53
for
(
const
auto
& elem :
DomChildren
(parent,
"child"
))
54
texts << elem.text ();
55
QCOMPARE (texts, QStringList {
"foo"
});
56
}
57
58
void
DomChildrenRangeTest::testMultiple ()
59
{
60
const
auto
& parent = MakeDocument (R
"(
61
<root>
62
<child>foo</child>
63
<child>bar</child>
64
<child>baz</child>
65
</root>
66
)");
67
68
QStringList texts;
69
for
(
const
auto
& elem :
DomChildren
(parent,
"child"
))
70
texts << elem.text ();
71
QCOMPARE (texts, (QStringList {
"foo"
,
"bar"
,
"baz"
}));
72
}
73
}
74
}
LC::Util::DomChildrenRangeTest
Definition
domchildrenrangetest.h:18
domchildrenrange.h
domchildrenrangetest.h
LC::Util
Definition
icoreproxy.h:34
LC::Util::DomChildren
auto DomChildren(const QDomNode &parent, const QString &tag)
Creates a range iterating over direct children named tag.
Definition
domchildrenrange.h:43
LC
Definition
constants.h:15
src
util
sll
tests
domchildrenrangetest.cpp
Generated by
1.17.0