summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestelementattribute.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/qtestelementattribute.cpp')
-rw-r--r--src/testlib/qtestelementattribute.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/testlib/qtestelementattribute.cpp b/src/testlib/qtestelementattribute.cpp
new file mode 100644
index 0000000..64f9da5
--- /dev/null
+++ b/src/testlib/qtestelementattribute.cpp
@@ -0,0 +1,76 @@
+#include "qtestelementattribute.h"
+#include <QtCore/qbytearray.h>
+#include <string.h>
+#include <stdlib.h>
+
+QT_BEGIN_NAMESPACE
+
+QTestElementAttribute::QTestElementAttribute()
+ :attributeValue(0),
+ attributeIndex(QTest::AI_Undefined)
+{
+}
+
+QTestElementAttribute::~QTestElementAttribute()
+{
+ delete[] attributeValue;
+}
+
+const char *QTestElementAttribute::value() const
+{
+ return attributeValue;
+}
+
+const char *QTestElementAttribute::name() const
+{
+ const char *AttributeNames[] =
+ {
+ "name",
+ "result",
+ "tests",
+ "failures",
+ "errors",
+ "type",
+ "description",
+ "value",
+ "qtestversion",
+ "qtversion",
+ "file",
+ "line",
+ "metric",
+ "tag",
+ "value",
+ "iterations"
+ };
+
+ if(attributeIndex != QTest::AI_Undefined)
+ return AttributeNames[attributeIndex];
+
+ return 0;
+}
+
+QTest::AttributeIndex QTestElementAttribute::index() const
+{
+ return attributeIndex;
+}
+
+bool QTestElementAttribute::isNull() const
+{
+ return attributeIndex == QTest::AI_Undefined;
+}
+
+bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value)
+{
+ if(!value)
+ return false;
+
+ delete[] attributeValue;
+
+ attributeIndex = index;
+ attributeValue = qstrdup(value);
+
+ return (attributeValue!=0) ? true:false;
+}
+
+QT_END_NAMESPACE
+