OpenCoverage

qtestxunitstreamer.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/testlib/qtestxunitstreamer.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger)-
5 : testLogger(logger)-
6{-
7 do { if (!(testLogger)
!(testLogger)Description
TRUEnever evaluated
FALSEevaluated 215 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) qt_assert("testLogger",__FILE__,54);
never executed: qt_assert("testLogger",__FILE__,54);
} while (0);
0-215
8}
executed 215 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
215
9-
10QTestXunitStreamer::~QTestXunitStreamer()-
11{}-
12-
13void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf, int size)-
14{-
15 if (size == 0
size == 0Description
TRUEnever evaluated
FALSEevaluated 35404 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) return;
never executed: return;
0-35404
16-
17 buf[0] = 0;-
18-
19 if (!element
!elementDescription
TRUEnever evaluated
FALSEevaluated 35404 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) return;
never executed: return;
0-35404
20-
21 char* endbuf = buf + size;-
22 element = element->parentElement();-
23 while (element
elementDescription
TRUEevaluated 66938 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 35404 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
&& buf+2 < endbuf
buf+2 < endbufDescription
TRUEevaluated 66938 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEnever evaluated
) {
0-66938
24 *(buf++) = ' ';-
25 *(buf++) = ' ';-
26 *buf = 0;-
27 element = element->parentElement();-
28 }
executed 66938 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
66938
29}
executed 35404 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
35404
30-
31void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const-
32{-
33 if (!element
!elementDescription
TRUEnever evaluated
FALSEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| !formatted
!formattedDescription
TRUEnever evaluated
FALSEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
0-33934
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
element->eleme...est::LET_ErrorDescription
TRUEevaluated 30566 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 3368 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
3368-30566
41 if (element->parentElement()->elementType() == QTest::LET_SystemError
element->paren...ET_SystemErrorDescription
TRUEevaluated 15283 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 15283 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
15283
42 QTest::qt_asprintf(formatted, "<![CDATA[");-
43 }
executed 15283 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
else {
15283
44 QTest::qt_asprintf(formatted, "%s<!--", indent);-
45 }
executed 15283 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
15283
46 return;
executed 30566 times by 1 test: return;
Executed by:
  • tst_selftests - unknown status
30566
47 }-
48-
49 QTest::qt_asprintf(formatted, "%s<%s", indent, element->elementName());-
50}
executed 3368 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
3368
51-
52void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const-
53{-
54 if (!element
!elementDescription
TRUEnever evaluated
FALSEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| !formatted
!formattedDescription
TRUEnever evaluated
FALSEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
0-33934
55 return;
never executed: return;
0
56-
57 if (!element->childElements()
!element->childElements()Description
TRUEevaluated 32464 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 1470 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
1470-32464
58 formatted->data()[0] = '\0';-
59 return;
executed 32464 times by 1 test: return;
Executed by:
  • tst_selftests - unknown status
32464
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}
executed 1470 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
1470
67-
68void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const-
69{-
70 if (!attribute
!attributeDescription
TRUEnever evaluated
FALSEevaluated 88028 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| !formatted
!formattedDescription
TRUEnever evaluated
FALSEevaluated 88028 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
0-88028
71 return;
never executed: return;
0
72-
73 QTest::AttributeIndex attrindex = attribute->index();-
74-
75-
76 if (element
elementDescription
TRUEevaluated 88028 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEnever evaluated
&& element->elementType() == QTest::LET_Error
element->eleme...est::LET_ErrorDescription
TRUEevaluated 77343 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 10685 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
0-88028
77 && element->parentElement()->elementType() == QTest::LET_SystemError
element->paren...ET_SystemErrorDescription
TRUEevaluated 15283 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 62060 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
15283-62060
78-
79 if (attrindex != QTest::AI_Description
attrindex != Q...AI_DescriptionDescription
TRUEnever evaluated
FALSEevaluated 15283 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) return;
never executed: return;
0-15283
80-
81 QXmlTestLogger::xmlCdata(formatted, attribute->value());-
82 return;
executed 15283 times by 1 test: return;
Executed by:
  • tst_selftests - unknown status
15283
83 }-
84-
85 char const* key = 0;-
86 if (attrindex == QTest::AI_Description
attrindex == Q...AI_DescriptionDescription
TRUEevaluated 16036 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 56709 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
16036-56709
87 key = "message";
executed 16036 times by 1 test: key = "message";
Executed by:
  • tst_selftests - unknown status
16036
88 else if (attrindex != QTest::AI_File
attrindex != QTest::AI_FileDescription
TRUEevaluated 39439 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 17270 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
&& attrindex != QTest::AI_Line
attrindex != QTest::AI_LineDescription
TRUEevaluated 22169 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 17270 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
17270-39439
89 key = attribute->name();
executed 22169 times by 1 test: key = attribute->name();
Executed by:
  • tst_selftests - unknown status
22169
90-
91 if (key
keyDescription
TRUEevaluated 38205 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 34540 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
34540-38205
92 QTestCharBuffer quotedValue;-
93 QXmlTestLogger::xmlQuote(&quotedValue, attribute->value());-
94 QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData());-
95 }
executed 38205 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
else {
38205
96 formatted->data()[0] = '\0';-
97 }
executed 34540 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
34540
98}-
99-
100void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const-
101{-
102 if (!element
!elementDescription
TRUEnever evaluated
FALSEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| !formatted
!formattedDescription
TRUEnever evaluated
FALSEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
0-33934
103 return;
never executed: return;
0
104-
105-
106 if (element->elementType() == QTest::LET_Error
element->eleme...est::LET_ErrorDescription
TRUEevaluated 30566 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 3368 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
3368-30566
107 if (element->parentElement()->elementType() == QTest::LET_SystemError
element->paren...ET_SystemErrorDescription
TRUEevaluated 15283 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 15283 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
15283
108 QTest::qt_asprintf(formatted, "]]>\n");-
109 }
executed 15283 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
else {
15283
110 QTest::qt_asprintf(formatted, " -->\n");-
111 }
executed 15283 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
15283
112 return;
executed 30566 times by 1 test: return;
Executed by:
  • tst_selftests - unknown status
30566
113 }-
114-
115 if (!element->childElements()
!element->childElements()Description
TRUEevaluated 1898 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 1470 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
1470-1898
116 QTest::qt_asprintf(formatted, "/>\n");
executed 1898 times by 1 test: QTest::qt_asprintf(formatted, "/>\n");
Executed by:
  • tst_selftests - unknown status
1898
117 else-
118 QTest::qt_asprintf(formatted, ">\n");
executed 1470 times by 1 test: QTest::qt_asprintf(formatted, ">\n");
Executed by:
  • tst_selftests - unknown status
1470
119}-
120-
121void QTestXunitStreamer::output(QTestElement *element) const-
122{-
123 do { if (!(element)
!(element)Description
TRUEnever evaluated
FALSEevaluated 215 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) qt_assert("element",__FILE__,170);
never executed: qt_assert("element",__FILE__,170);
} while (0);
0-215
124-
125 outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");-
126 outputElements(element);-
127}
executed 215 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
215
128-
129void QTestXunitStreamer::outputElements(QTestElement *element, bool) const-
130{-
131 QTestCharBuffer buf;-
132 bool hasChildren;-
133-
134-
135-
136-
137 while (element
elementDescription
TRUEevaluated 34010 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEnever evaluated
&& element->nextElement()
element->nextElement()Description
TRUEevaluated 32325 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 1685 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
0-34010
138 element = element->nextElement();-
139 }
executed 32325 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
32325
140 while (element
elementDescription
TRUEevaluated 34010 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 1685 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
1685-34010
141 hasChildren = element->childElements();-
142-
143 if (element->elementType() != QTest::LET_Benchmark
element->eleme...:LET_BenchmarkDescription
TRUEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 76 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
76-33934
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
hasChildrenDescription
TRUEevaluated 1470 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 32464 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
1470-32464
153 outputElements(element->childElements(), true);
executed 1470 times by 1 test: outputElements(element->childElements(), true);
Executed by:
  • tst_selftests - unknown status
1470
154-
155 formatEnd(element, &buf);-
156 outputString(buf.data());-
157 }
executed 33934 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
33934
158 element = element->previousElement();-
159 }
executed 34010 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
34010
160}
executed 1685 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
1685
161-
162void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const-
163{-
164 QTestCharBuffer buf;-
165 while (attribute
attributeDescription
TRUEevaluated 88028 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 33934 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
33934-88028
166 formatAttributes(element, attribute, &buf);-
167 outputString(buf.data());-
168 attribute = attribute->nextElement();-
169 }
executed 88028 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
88028
170}
executed 33934 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
33934
171-
172void QTestXunitStreamer::outputString(const char *msg) const-
173{-
174 testLogger->outputString(msg);-
175}
executed 190045 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
190045
176-
177-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9