qtestxunitstreamer.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger) -
5 : testLogger(logger) -
6{ -
7 do { if (!(testLogger)) qt_assert("testLogger","qtestxunitstreamer.cpp",56); } while (0);
never executed: qt_assert("testLogger","qtestxunitstreamer.cpp",56);
never executed: }
never evaluated: !(testLogger)
never evaluated: 0
0
8}
never executed: }
0
9 -
10QTestXunitStreamer::~QTestXunitStreamer() -
11{} -
12 -
13void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf, int size) -
14{ -
15 if (size == 0) return;
never executed: return;
never evaluated: size == 0
0
16 -
17 buf[0] = 0; -
18 -
19 if (!element) return;
never executed: return;
never evaluated: !element
0
20 -
21 char* endbuf = buf + size; -
22 element = element->parentElement(); -
23 while (element && buf+2 < endbuf) {
never evaluated: element
never evaluated: buf+2 < endbuf
0
24 *(buf++) = ' '; -
25 *(buf++) = ' '; -
26 *buf = 0; -
27 element = element->parentElement(); -
28 }
never executed: }
0
29}
never executed: }
0
30 -
31void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const -
32{ -
33 if (!element || !formatted )
never evaluated: !element
never evaluated: !formatted
0
34 return;
never executed: return;
0
35 -
36 char indent[20]; -
37 indentForElement(element, indent, sizeof(indent)); -
38 -
39 -
40 if (element->elementType() == QTest::LET_Error) {
never evaluated: element->elementType() == QTest::LET_Error
0
41 if (element->parentElement()->elementType() == QTest::LET_SystemError) {
never evaluated: element->parentElement()->elementType() == QTest::LET_SystemError
0
42 QTest::qt_asprintf(formatted, "<![CDATA["); -
43 } else {
never executed: }
0
44 QTest::qt_asprintf(formatted, "%s<!--", indent); -
45 }
never executed: }
0
46 return;
never executed: return;
0
47 } -
48 -
49 QTest::qt_asprintf(formatted, "%s<%s", indent, element->elementName()); -
50}
never executed: }
0
51 -
52void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const -
53{ -
54 if (!element || !formatted )
never evaluated: !element
never evaluated: !formatted
0
55 return;
never executed: return;
0
56 -
57 if (!element->childElements()) {
never evaluated: !element->childElements()
0
58 formatted->data()[0] = '\0'; -
59 return;
never executed: return;
0
60 } -
61 -
62 char indent[20]; -
63 indentForElement(element, indent, sizeof(indent)); -
64 -
65 QTest::qt_asprintf(formatted, "%s</%s>\n", indent, element->elementName()); -
66}
never executed: }
0
67 -
68void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const -
69{ -
70 if (!attribute || !formatted )
never evaluated: !attribute
never evaluated: !formatted
0
71 return;
never executed: return;
0
72 -
73 QTest::AttributeIndex attrindex = attribute->index(); -
74 -
75 -
76 if (element && element->elementType() == QTest::LET_Error
never evaluated: element
never evaluated: element->elementType() == QTest::LET_Error
0
77 && element->parentElement()->elementType() == QTest::LET_SystemError) {
never evaluated: element->parentElement()->elementType() == QTest::LET_SystemError
0
78 -
79 if (attrindex != QTest::AI_Description) return;
never executed: return;
never evaluated: attrindex != QTest::AI_Description
0
80 -
81 QXmlTestLogger::xmlCdata(formatted, attribute->value()); -
82 return;
never executed: return;
0
83 } -
84 -
85 char const* key = 0; -
86 if (attrindex == QTest::AI_Description)
never evaluated: attrindex == QTest::AI_Description
0
87 key = "message";
never executed: key = "message";
0
88 else if (attrindex != QTest::AI_File && attrindex != QTest::AI_Line)
never evaluated: attrindex != QTest::AI_File
never evaluated: attrindex != QTest::AI_Line
0
89 key = attribute->name();
never executed: key = attribute->name();
0
90 -
91 if (key) {
never evaluated: key
0
92 QTestCharBuffer quotedValue; -
93 QXmlTestLogger::xmlQuote(&quotedValue, attribute->value()); -
94 QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData()); -
95 } else {
never executed: }
0
96 formatted->data()[0] = '\0'; -
97 }
never executed: }
0
98} -
99 -
100void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const -
101{ -
102 if (!element || !formatted )
never evaluated: !element
never evaluated: !formatted
0
103 return;
never executed: return;
0
104 -
105 -
106 if (element->elementType() == QTest::LET_Error) {
never evaluated: element->elementType() == QTest::LET_Error
0
107 if (element->parentElement()->elementType() == QTest::LET_SystemError) {
never evaluated: element->parentElement()->elementType() == QTest::LET_SystemError
0
108 QTest::qt_asprintf(formatted, "]]>\n"); -
109 } else {
never executed: }
0
110 QTest::qt_asprintf(formatted, " -->\n"); -
111 }
never executed: }
0
112 return;
never executed: return;
0
113 } -
114 -
115 if (!element->childElements())
never evaluated: !element->childElements()
0
116 QTest::qt_asprintf(formatted, "/>\n");
never executed: QTest::qt_asprintf(formatted, "/>\n");
0
117 else -
118 QTest::qt_asprintf(formatted, ">\n");
never executed: QTest::qt_asprintf(formatted, ">\n");
0
119} -
120 -
121void QTestXunitStreamer::output(QTestElement *element) const -
122{ -
123 do { if (!(element)) qt_assert("element","qtestxunitstreamer.cpp",172); } while (0);
never executed: qt_assert("element","qtestxunitstreamer.cpp",172);
never executed: }
never evaluated: !(element)
never evaluated: 0
0
124 -
125 outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); -
126 outputElements(element); -
127}
never executed: }
0
128 -
129void QTestXunitStreamer::outputElements(QTestElement *element, bool) const -
130{ -
131 QTestCharBuffer buf; -
132 bool hasChildren; -
133 -
134 -
135 -
136 -
137 while (element && element->nextElement()) {
never evaluated: element
never evaluated: element->nextElement()
0
138 element = element->nextElement(); -
139 }
never executed: }
0
140 while (element) {
never evaluated: element
0
141 hasChildren = element->childElements(); -
142 -
143 if (element->elementType() != QTest::LET_Benchmark) {
never evaluated: element->elementType() != QTest::LET_Benchmark
0
144 formatStart(element, &buf); -
145 outputString(buf.data()); -
146 -
147 outputElementAttributes(element, element->attributes()); -
148 -
149 formatAfterAttributes(element, &buf); -
150 outputString(buf.data()); -
151 -
152 if (hasChildren)
never evaluated: hasChildren
0
153 outputElements(element->childElements(), true);
never executed: outputElements(element->childElements(), true);
0
154 -
155 formatEnd(element, &buf); -
156 outputString(buf.data()); -
157 }
never executed: }
0
158 element = element->previousElement(); -
159 }
never executed: }
0
160}
never executed: }
0
161 -
162void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const -
163{ -
164 QTestCharBuffer buf; -
165 while (attribute) {
never evaluated: attribute
0
166 formatAttributes(element, attribute, &buf); -
167 outputString(buf.data()); -
168 attribute = attribute->nextElement(); -
169 }
never executed: }
0
170}
never executed: }
0
171 -
172void QTestXunitStreamer::outputString(const char *msg) const -
173{ -
174 testLogger->outputString(msg); -
175}
never executed: }
0
176 -
177 -
178 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial