1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the QtTest module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
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 Digia. For licensing terms and |
14 | ** conditions see http://qt.digia.com/licensing. For further information |
15 | ** use the contact form at http://qt.digia.com/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 2.1 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
24 | ** |
25 | ** In addition, as a special exception, Digia gives you certain additional |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
28 | ** |
29 | ** GNU General Public License Usage |
30 | ** Alternatively, this file may be used under the terms of the GNU |
31 | ** General Public License version 3.0 as published by the Free Software |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
33 | ** packaging of this file. Please review the following information to |
34 | ** ensure the GNU General Public License version 3.0 requirements will be |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #include "qtestelementattribute.h" |
43 | #include <QtCore/qbytearray.h> |
44 | #include <string.h> |
45 | #include <stdlib.h> |
46 | |
47 | QT_BEGIN_NAMESPACE |
48 | |
49 | /*! \enum QTest::AttributeIndex |
50 | This enum numbers the different tests. |
51 | |
52 | \value AI_Undefined |
53 | |
54 | \value AI_Name |
55 | |
56 | \value AI_Result |
57 | |
58 | \value AI_Tests |
59 | |
60 | \value AI_Failures |
61 | |
62 | \value AI_Errors |
63 | |
64 | \value AI_Type |
65 | |
66 | \value AI_Description |
67 | |
68 | \value AI_PropertyValue |
69 | |
70 | \value AI_QTestVersion |
71 | |
72 | \value AI_QtVersion |
73 | |
74 | \value AI_File |
75 | |
76 | \value AI_Line |
77 | |
78 | \value AI_Metric |
79 | |
80 | \value AI_Tag |
81 | |
82 | \value AI_Value |
83 | |
84 | \value AI_Iterations |
85 | */ |
86 | |
87 | /*! \enum QTest::LogElementType |
88 | The enum specifies the kinds of test log messages. |
89 | |
90 | \value LET_Undefined |
91 | |
92 | \value LET_Property |
93 | |
94 | \value LET_Properties |
95 | |
96 | \value LET_Failure |
97 | |
98 | \value LET_Error |
99 | |
100 | \value LET_TestCase |
101 | |
102 | \value LET_TestSuite |
103 | |
104 | \value LET_Benchmark |
105 | |
106 | \value LET_SystemError |
107 | */ |
108 | |
109 | QTestElementAttribute::QTestElementAttribute() |
110 | :attributeValue(0), |
111 | attributeIndex(QTest::AI_Undefined) |
112 | { |
113 | } |
114 | |
115 | QTestElementAttribute::~QTestElementAttribute() |
116 | { |
117 | delete[] attributeValue; |
118 | } |
119 | |
120 | const char *QTestElementAttribute::value() const |
121 | { |
122 | return attributeValue; |
123 | } |
124 | |
125 | const char *QTestElementAttribute::name() const |
126 | { |
127 | const char *AttributeNames[] = |
128 | { |
129 | "name" , |
130 | "result" , |
131 | "tests" , |
132 | "failures" , |
133 | "errors" , |
134 | "type" , |
135 | "description" , |
136 | "value" , |
137 | "qtestversion" , |
138 | "qtversion" , |
139 | "file" , |
140 | "line" , |
141 | "metric" , |
142 | "tag" , |
143 | "value" , |
144 | "iterations" |
145 | }; |
146 | |
147 | if(attributeIndex != QTest::AI_Undefined) |
148 | return AttributeNames[attributeIndex]; |
149 | |
150 | return 0; |
151 | } |
152 | |
153 | QTest::AttributeIndex QTestElementAttribute::index() const |
154 | { |
155 | return attributeIndex; |
156 | } |
157 | |
158 | bool QTestElementAttribute::isNull() const |
159 | { |
160 | return attributeIndex == QTest::AI_Undefined; |
161 | } |
162 | |
163 | bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value) |
164 | { |
165 | if(!value) |
166 | return false; |
167 | |
168 | delete[] attributeValue; |
169 | |
170 | attributeIndex = index; |
171 | attributeValue = qstrdup(value); |
172 | |
173 | return (attributeValue!=0) ? true:false; |
174 | } |
175 | |
176 | QT_END_NAMESPACE |
177 | |
178 | |