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