| 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__,48); | 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-35334 | ||||||||||||
| 16 | - | |||||||||||||
| 17 | buf[0] = 0; | - | ||||||||||||
| 18 | - | |||||||||||||
| 19 |     if (!element
 never executed:  return; | 0-35334 | ||||||||||||
| 20 | - | |||||||||||||
| 21 | char* endbuf = buf + size; | - | ||||||||||||
| 22 | element = element->parentElement(); | - | ||||||||||||
| 23 |     while (element
 
  | 0-66840 | ||||||||||||
| 24 | *(buf++) = ' '; | - | ||||||||||||
| 25 | *(buf++) = ' '; | - | ||||||||||||
| 26 | *buf = 0; | - | ||||||||||||
| 27 | element = element->parentElement(); | - | ||||||||||||
| 28 |     } executed 66840 times by 1 test:  end of blockExecuted by: 
  | 66840 | ||||||||||||
| 29 | } executed 35334 times by 1 test:  end of blockExecuted by: 
  | 35334 | ||||||||||||
| 30 | - | |||||||||||||
| 31 | void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const | - | ||||||||||||
| 32 | { | - | ||||||||||||
| 33 |     if (!element
 
  | 0-33885 | ||||||||||||
| 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
  | 3319-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 3319 times by 1 test:  end of blockExecuted by: 
  | 3319 | ||||||||||||
| 51 | - | |||||||||||||
| 52 | void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const | - | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 |     if (!element
 
  | 0-33885 | ||||||||||||
| 55 |         return; never executed:  return; | 0 | ||||||||||||
| 56 | - | |||||||||||||
| 57 |     if (!element->childElements()
  | 1449-32436 | ||||||||||||
| 58 | formatted->data()[0] = '\0'; | - | ||||||||||||
| 59 |         return; executed 32436 times by 1 test:  return;Executed by: 
  | 32436 | ||||||||||||
| 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 1449 times by 1 test:  end of blockExecuted by: 
  | 1449 | ||||||||||||
| 67 | - | |||||||||||||
| 68 | void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const | - | ||||||||||||
| 69 | { | - | ||||||||||||
| 70 |     if (!attribute
 
  | 0-87818 | ||||||||||||
| 71 |         return; never executed:  return; | 0 | ||||||||||||
| 72 | - | |||||||||||||
| 73 | QTest::AttributeIndex attrindex = attribute->index(); | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | - | |||||||||||||
| 76 |     if (element
 
  | 0-87818 | ||||||||||||
| 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
  | 16008-56527 | ||||||||||||
| 87 |         key = "message"; executed 16008 times by 1 test:  key = "message";Executed by: 
  | 16008 | ||||||||||||
| 88 |     else if (attrindex != QTest::AI_File
 
  | 17221-39306 | ||||||||||||
| 89 |         key = attribute->name(); executed 22085 times by 1 test:  key = attribute->name();Executed by: 
  | 22085 | ||||||||||||
| 90 | - | |||||||||||||
| 91 |     if (key
  | 34442-38093 | ||||||||||||
| 92 | QTestCharBuffer quotedValue; | - | ||||||||||||
| 93 | QXmlTestLogger::xmlQuote("edValue, attribute->value()); | - | ||||||||||||
| 94 | QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData()); | - | ||||||||||||
| 95 |     } executed 38093 times by 1 test:   else {end of blockExecuted by: 
  | 38093 | ||||||||||||
| 96 | formatted->data()[0] = '\0'; | - | ||||||||||||
| 97 |     } executed 34442 times by 1 test:  end of blockExecuted by: 
  | 34442 | ||||||||||||
| 98 | } | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const | - | ||||||||||||
| 101 | { | - | ||||||||||||
| 102 |     if (!element
 
  | 0-33885 | ||||||||||||
| 103 |         return; never executed:  return; | 0 | ||||||||||||
| 104 | - | |||||||||||||
| 105 | - | |||||||||||||
| 106 |     if (element->elementType() == QTest::LET_Error
  | 3319-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()
  | 1449-1870 | ||||||||||||
| 116 |         QTest::qt_asprintf(formatted, "/>\n"); executed 1870 times by 1 test:  QTest::qt_asprintf(formatted, "/>\n");Executed by: 
  | 1870 | ||||||||||||
| 117 | else | - | ||||||||||||
| 118 |         QTest::qt_asprintf(formatted, ">\n"); executed 1449 times by 1 test:  QTest::qt_asprintf(formatted, ">\n");Executed by: 
  | 1449 | ||||||||||||
| 119 | } | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | void QTestXunitStreamer::output(QTestElement *element) const | - | ||||||||||||
| 122 | { | - | ||||||||||||
| 123 |     do { if (!(element)
 never executed:   } while (0);qt_assert("element",__FILE__,164); | 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-33961 | ||||||||||||
| 138 | element = element->nextElement(); | - | ||||||||||||
| 139 |     } executed 32297 times by 1 test:  end of blockExecuted by: 
  | 32297 | ||||||||||||
| 140 |     while (element
  | 1664-33961 | ||||||||||||
| 141 | hasChildren = element->childElements(); | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 |         if (element->elementType() != QTest::LET_Benchmark
  | 76-33885 | ||||||||||||
| 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
  | 1449-32436 | ||||||||||||
| 153 |                 outputElements(element->childElements(), true); executed 1449 times by 1 test:  outputElements(element->childElements(), true);Executed by: 
  | 1449 | ||||||||||||
| 154 | - | |||||||||||||
| 155 | formatEnd(element, &buf); | - | ||||||||||||
| 156 | outputString(buf.data()); | - | ||||||||||||
| 157 |         } executed 33885 times by 1 test:  end of blockExecuted by: 
  | 33885 | ||||||||||||
| 158 | element = element->previousElement(); | - | ||||||||||||
| 159 |     } executed 33961 times by 1 test:  end of blockExecuted by: 
  | 33961 | ||||||||||||
| 160 | } executed 1664 times by 1 test:  end of blockExecuted by: 
  | 1664 | ||||||||||||
| 161 | - | |||||||||||||
| 162 | void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const | - | ||||||||||||
| 163 | { | - | ||||||||||||
| 164 | QTestCharBuffer buf; | - | ||||||||||||
| 165 |     while (attribute
  | 33885-87818 | ||||||||||||
| 166 | formatAttributes(element, attribute, &buf); | - | ||||||||||||
| 167 | outputString(buf.data()); | - | ||||||||||||
| 168 | attribute = attribute->nextElement(); | - | ||||||||||||
| 169 |     } executed 87818 times by 1 test:  end of blockExecuted by: 
  | 87818 | ||||||||||||
| 170 | } executed 33885 times by 1 test:  end of blockExecuted by: 
  | 33885 | ||||||||||||
| 171 | - | |||||||||||||
| 172 | void QTestXunitStreamer::outputString(const char *msg) const | - | ||||||||||||
| 173 | { | - | ||||||||||||
| 174 | testLogger->outputString(msg); | - | ||||||||||||
| 175 | } executed 189688 times by 1 test:  end of blockExecuted by: 
  | 189688 | ||||||||||||
| 176 | - | |||||||||||||
| 177 | - | |||||||||||||
| Switch to Source code | Preprocessed file |