Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/vcs/tests/test_vcsstatusinfo.cpp
- This file was added.
1 | /* This file is part of KDevelop | ||||
---|---|---|---|---|---|
2 | * | ||||
3 | * Copyright 2017 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
4 | * | ||||
5 | * This program is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU General Public License | ||||
7 | * as published by the Free Software Foundation; either version 2 | ||||
8 | * of the License, or (at your option) any later version. | ||||
9 | * | ||||
10 | * This program is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | * GNU General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU General Public License | ||||
16 | * along with this program; if not, write to the Free Software | ||||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||||
18 | * 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #include "test_vcsstatusinfo.h" | ||||
22 | | ||||
23 | #include <QTest> | ||||
24 | | ||||
25 | using namespace KDevelop; | ||||
26 | | ||||
27 | void TestVcsStatusInfo::testCopyConstructor() | ||||
28 | { | ||||
29 | // test plain copy | ||||
30 | const QUrl url(QStringLiteral("git://foo")); | ||||
31 | const VcsStatusInfo::State state = VcsStatusInfo::ItemUpToDate; | ||||
32 | | ||||
33 | { | ||||
34 | VcsStatusInfo statusInfoA; | ||||
35 | statusInfoA.setUrl(url); | ||||
36 | statusInfoA.setState(state); | ||||
37 | | ||||
38 | VcsStatusInfo statusInfoB(statusInfoA); | ||||
39 | | ||||
40 | QCOMPARE(statusInfoA.url(), url); | ||||
41 | QCOMPARE(statusInfoA.state(), state); | ||||
42 | QCOMPARE(statusInfoB.url(), url); | ||||
43 | QCOMPARE(statusInfoB.state(), state); | ||||
44 | QVERIFY(statusInfoA == statusInfoB); | ||||
45 | QVERIFY(statusInfoB == statusInfoA); | ||||
46 | } | ||||
47 | | ||||
48 | const QUrl urlNew(QStringLiteral("svn://bar")); | ||||
49 | | ||||
50 | // test detach after changing A | ||||
51 | { | ||||
52 | VcsStatusInfo statusInfoA; | ||||
53 | statusInfoA.setUrl(url); | ||||
54 | statusInfoA.setState(state); | ||||
55 | | ||||
56 | VcsStatusInfo statusInfoB(statusInfoA); | ||||
57 | // change a property of A | ||||
58 | statusInfoA.setUrl(urlNew); | ||||
59 | | ||||
60 | QCOMPARE(statusInfoA.url(), urlNew); | ||||
61 | QCOMPARE(statusInfoA.state(), state); | ||||
62 | QCOMPARE(statusInfoB.url(), url); | ||||
63 | QCOMPARE(statusInfoB.state(), state); | ||||
64 | QVERIFY(statusInfoA != statusInfoB); | ||||
65 | QVERIFY(statusInfoB != statusInfoA); | ||||
66 | } | ||||
67 | } | ||||
68 | | ||||
69 | void TestVcsStatusInfo::testAssignOperator() | ||||
70 | { | ||||
71 | // test plain copy | ||||
72 | const QUrl url(QStringLiteral("git://foo")); | ||||
73 | const VcsStatusInfo::State state = VcsStatusInfo::ItemUpToDate; | ||||
74 | | ||||
75 | { | ||||
76 | VcsStatusInfo statusInfoA; | ||||
77 | statusInfoA.setUrl(url); | ||||
78 | statusInfoA.setState(state); | ||||
79 | | ||||
80 | VcsStatusInfo statusInfoB; | ||||
81 | statusInfoB = statusInfoA; | ||||
82 | | ||||
83 | QCOMPARE(statusInfoA.url(), url); | ||||
84 | QCOMPARE(statusInfoA.state(), state); | ||||
85 | QCOMPARE(statusInfoB.url(), url); | ||||
86 | QCOMPARE(statusInfoB.state(), state); | ||||
87 | QVERIFY(statusInfoA == statusInfoB); | ||||
88 | QVERIFY(statusInfoB == statusInfoA); | ||||
89 | } | ||||
90 | | ||||
91 | const QUrl urlNew(QStringLiteral("svn://bar")); | ||||
92 | | ||||
93 | // test detach after changing A | ||||
94 | { | ||||
95 | VcsStatusInfo statusInfoA; | ||||
96 | statusInfoA.setUrl(url); | ||||
97 | statusInfoA.setState(state); | ||||
98 | | ||||
99 | VcsStatusInfo statusInfoB; | ||||
100 | statusInfoB = statusInfoA; | ||||
101 | // change a property of A | ||||
102 | statusInfoA.setUrl(urlNew); | ||||
103 | | ||||
104 | QCOMPARE(statusInfoA.url(), urlNew); | ||||
105 | QCOMPARE(statusInfoA.state(), state); | ||||
106 | QCOMPARE(statusInfoB.url(), url); | ||||
107 | QCOMPARE(statusInfoB.state(), state); | ||||
108 | QVERIFY(statusInfoA != statusInfoB); | ||||
109 | QVERIFY(statusInfoB != statusInfoA); | ||||
110 | } | ||||
111 | } | ||||
112 | | ||||
113 | QTEST_GUILESS_MAIN(TestVcsStatusInfo); |