blob: 1dd1a552bb745f6c0de95cff2cf95973e6114f96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt for Python project.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "testremoveoperatormethod.h"
#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetalang.h>
#include <typesystem.h>
void TestRemoveOperatorMethod::testRemoveOperatorMethod()
{
const char* cppCode ="\
#include <stdint.h>\n\
\n\
struct Char {};\n\
struct ByteArray {};\n\
struct String {};\n\
\n\
struct A {\n\
A& operator>>(char&);\n\
A& operator>>(char*);\n\
A& operator>>(short&);\n\
A& operator>>(unsigned short&);\n\
A& operator>>(int&);\n\
A& operator>>(unsigned int&);\n\
A& operator>>(int64_t&);\n\
A& operator>>(uint64_t&);\n\
A& operator>>(float&);\n\
A& operator>>(double&);\n\
A& operator>>(Char&);\n\
A& operator>>(ByteArray&);\n\
A& operator>>(String&);\n\
};\n";
const char* xmlCode = "\
<typesystem package='Foo'>\n\
<primitive-type name='char'/>\n\
<primitive-type name='short'/>\n\
<primitive-type name='unsigned short'/>\n\
<primitive-type name='int'/>\n\
<primitive-type name='unsigned int'/>\n\
<primitive-type name='int64_t'/>\n\
<primitive-type name='uint64_t'/>\n\
<primitive-type name='float'/>\n\
<primitive-type name='double'/>\n\
<primitive-type name='Char'/>\n\
<primitive-type name='String'/>\n\
<value-type name='ByteArray'/>\n\
<object-type name='A'>\n\
<modify-function signature='operator>>(char&)' remove='all'/>\n\
<modify-function signature='operator>>(char*)' remove='all'/>\n\
<modify-function signature='operator>>(short&)' remove='all'/>\n\
<modify-function signature='operator>>(unsigned short&)' remove='all'/>\n\
<modify-function signature='operator>>(int&)' remove='all'/>\n\
<modify-function signature='operator>>(unsigned int&)' remove='all'/>\n\
<modify-function signature='operator>>(int64_t&)' remove='all'/>\n\
<modify-function signature='operator>>(uint64_t&)' remove='all'/>\n\
<modify-function signature='operator>>(float&)' remove='all'/>\n\
<modify-function signature='operator>>(double&)' remove='all'/>\n\
<modify-function signature='operator>>(Char&)' remove='all'/>\n\
<modify-function signature='operator>>(String&)' remove='all'/>\n\
</object-type>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, QLatin1String("A"));
QVERIFY(classA);
QCOMPARE(classA->functions().size(), 14);
QStringList removedSignatures;
removedSignatures.append(QLatin1String("operator>>(char&)"));
removedSignatures.append(QLatin1String("operator>>(char*)"));
removedSignatures.append(QLatin1String("operator>>(short&)"));
removedSignatures.append(QLatin1String("operator>>(unsigned short&)"));
removedSignatures.append(QLatin1String("operator>>(int&)"));
removedSignatures.append(QLatin1String("operator>>(unsigned int&)"));
removedSignatures.append(QLatin1String("operator>>(int64_t&)"));
removedSignatures.append(QLatin1String("operator>>(uint64_t&)"));
removedSignatures.append(QLatin1String("operator>>(float&)"));
removedSignatures.append(QLatin1String("operator>>(double&)"));
removedSignatures.append(QLatin1String("operator>>(Char&)"));
removedSignatures.append(QLatin1String("operator>>(String&)"));
int notRemoved = classA->functions().size();
const AbstractMetaFunctionList &functions = classA->functions();
for (const AbstractMetaFunction *f : functions) {
QCOMPARE(f->isModifiedRemoved(), bool(removedSignatures.contains(f->minimalSignature())));
notRemoved -= int(f->isModifiedRemoved());
}
QCOMPARE(notRemoved, 2);
}
QTEST_APPLESS_MAIN(TestRemoveOperatorMethod)
|