1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include <QtCore/QString>
30#include <QtTest/QtTest>
31
32#include <qplaceattribute.h>
33
34QT_USE_NAMESPACE
35
36class tst_QPlaceAttribute : public QObject
37{
38 Q_OBJECT
39
40public:
41 tst_QPlaceAttribute();
42
43private Q_SLOTS:
44 void constructorTest();
45 void operatorsTest();
46 void isEmptyTest();
47};
48
49tst_QPlaceAttribute::tst_QPlaceAttribute()
50{
51}
52
53void tst_QPlaceAttribute::constructorTest()
54{
55 QPlaceAttribute testObj;
56
57 QPlaceAttribute *testObjPtr = new QPlaceAttribute(testObj);
58 QVERIFY2(testObjPtr != NULL, "Copy constructor - null");
59 QVERIFY2(testObjPtr->label() == QString(), "Copy constructor - wrong label");
60 QVERIFY2(testObjPtr->text() == QString(), "Copy constructor - wrong text");
61 QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare");
62 delete testObjPtr;
63}
64
65void tst_QPlaceAttribute::operatorsTest()
66{
67 QPlaceAttribute testObj;
68 testObj.setLabel(QStringLiteral("label"));
69 QPlaceAttribute testObj2;
70 testObj2 = testObj;
71 QVERIFY2(testObj == testObj2, "Not copied correctly");
72 testObj2.setText(QStringLiteral("text"));
73 QVERIFY2(testObj != testObj2, "Object should be different");
74}
75
76void tst_QPlaceAttribute::isEmptyTest()
77{
78 QPlaceAttribute attribute;
79
80 QVERIFY(attribute.isEmpty());
81
82 attribute.setLabel(QStringLiteral("label"));
83 QVERIFY(!attribute.isEmpty());
84 attribute.setLabel(QString());
85 QVERIFY(attribute.isEmpty());
86
87 attribute.setText(QStringLiteral("text"));
88 QVERIFY(!attribute.isEmpty());
89 attribute.setText(QString());
90 QVERIFY(attribute.isEmpty());
91}
92
93QTEST_APPLESS_MAIN(tst_QPlaceAttribute);
94
95#include "tst_qplaceattribute.moc"
96

source code of qtlocation/tests/auto/qplaceattribute/tst_qplaceattribute.cpp