Changeset View
Changeset View
Standalone View
Standalone View
tests/test_functions.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2017 Jos van den Oever <jos@vandenoever.info> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #include "test_functions_rust.h" | ||||
22 | #include <QTest> | ||||
23 | #include <QSignalSpy> | ||||
24 | | ||||
25 | class TestRustObject : public QObject | ||||
26 | { | ||||
27 | Q_OBJECT | ||||
28 | private slots: | ||||
29 | void testConstructor(); | ||||
30 | void testStringFunction(); | ||||
31 | void testSimpleFunction(); | ||||
32 | void testVoidFunction(); | ||||
33 | }; | ||||
34 | | ||||
35 | void TestRustObject::testConstructor() | ||||
36 | { | ||||
37 | Person person; | ||||
38 | } | ||||
39 | | ||||
40 | void TestRustObject::testSimpleFunction() | ||||
41 | { | ||||
42 | // GIVEN | ||||
43 | Person person; | ||||
44 | person.setUserName("Konqi"); | ||||
45 | | ||||
46 | // THEN | ||||
47 | QCOMPARE((int)person.vowels_in_name(), 2); | ||||
48 | } | ||||
49 | | ||||
50 | void TestRustObject::testVoidFunction() | ||||
51 | { | ||||
52 | // GIVEN | ||||
53 | Person person; | ||||
54 | person.setUserName("Konqi"); | ||||
55 | | ||||
56 | // THEN | ||||
57 | person.double_name(); | ||||
58 | QCOMPARE(person.userName(), QString("KonqiKonqi")); | ||||
59 | } | ||||
60 | | ||||
61 | void TestRustObject::testStringFunction() | ||||
62 | { | ||||
63 | // GIVEN | ||||
64 | Person person; | ||||
65 | person.setUserName("Konqi"); | ||||
66 | | ||||
67 | // THEN | ||||
68 | QCOMPARE(person.greet("John"), QString("Hello John, my name is Konqi, how is it going?")); | ||||
69 | } | ||||
70 | | ||||
71 | QTEST_MAIN(TestRustObject) | ||||
72 | #include "test_functions.moc" |