1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtTest/private/qtestelementattribute_p.h>
5#include <QtCore/qbytearray.h>
6#include <string.h>
7#include <stdlib.h>
8
9QT_BEGIN_NAMESPACE
10
11QTestElementAttribute::QTestElementAttribute() = default;
12
13QTestElementAttribute::~QTestElementAttribute()
14{
15 delete[] attributeValue;
16}
17
18const char *QTestElementAttribute::value() const
19{
20 return attributeValue;
21}
22
23const char *QTestElementAttribute::name() const
24{
25 const char *AttributeNames[] =
26 {
27 "name",
28 "tests",
29 "failures",
30 "errors",
31 "type",
32 "message",
33 "value",
34 "value",
35 "time",
36 "timestamp",
37 "hostname",
38 "classname",
39 "skipped"
40 };
41
42 if (attributeIndex != QTest::AI_Undefined)
43 return AttributeNames[attributeIndex];
44
45 return nullptr;
46}
47
48QTest::AttributeIndex QTestElementAttribute::index() const
49{
50 return attributeIndex;
51}
52
53bool QTestElementAttribute::isNull() const
54{
55 return attributeIndex == QTest::AI_Undefined;
56}
57
58bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value)
59{
60 if (!value)
61 return false;
62
63 delete[] attributeValue;
64
65 attributeIndex = index;
66 attributeValue = qstrdup(value);
67
68 return attributeValue != nullptr;
69}
70
71QT_END_NAMESPACE
72
73

source code of qtbase/src/testlib/qtestelementattribute.cpp