| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/json/qjsonvalue.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | QJsonValue::QJsonValue(Type type) | - | ||||||||||||||||||
| 5 | : ui(0), d(0), t(type) | - | ||||||||||||||||||
| 6 | { | - | ||||||||||||||||||
| 7 | } executed 323 times by 7 tests: end of blockExecuted by:
| 323 | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | QJsonValue::QJsonValue(QJsonPrivate::Data *data, QJsonPrivate::Base *base, const QJsonPrivate::Value &v) | - | ||||||||||||||||||
| 13 | : d(0) | - | ||||||||||||||||||
| 14 | { | - | ||||||||||||||||||
| 15 | t = (Type)(uint)v.type; | - | ||||||||||||||||||
| 16 | switch (t) { | - | ||||||||||||||||||
| 17 | case never executed: Undefined:case Undefined:never executed: case Undefined: | 0 | ||||||||||||||||||
| 18 | case executed 1 time by 1 test: Null:case Null:Executed by:
executed 1 time by 1 test: case Null:Executed by:
| 1 | ||||||||||||||||||
| 19 | dbl = 0; | - | ||||||||||||||||||
| 20 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||
| 21 | case executed 655 times by 111 tests: Bool:case Bool:Executed by:
executed 655 times by 111 tests: case Bool:Executed by:
| 655 | ||||||||||||||||||
| 22 | b = v.toBoolean(); | - | ||||||||||||||||||
| 23 | break; executed 655 times by 111 tests: break;Executed by:
| 655 | ||||||||||||||||||
| 24 | case executed 1577 times by 113 tests: Double:case Double:Executed by:
executed 1577 times by 113 tests: case Double:Executed by:
| 1577 | ||||||||||||||||||
| 25 | dbl = v.toDouble(base); | - | ||||||||||||||||||
| 26 | break; executed 1577 times by 113 tests: break;Executed by:
| 1577 | ||||||||||||||||||
| 27 | case executed 69681 times by 114 tests: String:case String:Executed by:
executed 69681 times by 114 tests: {case String:Executed by:
| 69681 | ||||||||||||||||||
| 28 | QString s = v.toString(base); | - | ||||||||||||||||||
| 29 | stringData = s.data_ptr(); | - | ||||||||||||||||||
| 30 | stringData->ref.ref(); | - | ||||||||||||||||||
| 31 | break; executed 69681 times by 114 tests: break;Executed by:
| 69681 | ||||||||||||||||||
| 32 | } | - | ||||||||||||||||||
| 33 | case executed 41984 times by 113 tests: Array:case Array:Executed by:
executed 41984 times by 113 tests: case Array:Executed by:
| 41984 | ||||||||||||||||||
| 34 | case executed 42053 times by 114 tests: Object:case Object:Executed by:
executed 42053 times by 114 tests: case Object:Executed by:
| 42053 | ||||||||||||||||||
| 35 | d = data; | - | ||||||||||||||||||
| 36 | this->base = v.base(base); | - | ||||||||||||||||||
| 37 | break; executed 84037 times by 114 tests: break;Executed by:
| 84037 | ||||||||||||||||||
| 38 | } | - | ||||||||||||||||||
| 39 | if (d
| 71914-84037 | ||||||||||||||||||
| 40 | d->ref.ref(); executed 84037 times by 114 tests: d->ref.ref();Executed by:
| 84037 | ||||||||||||||||||
| 41 | } executed 155951 times by 116 tests: end of blockExecuted by:
| 155951 | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | QJsonValue::QJsonValue(bool b) | - | ||||||||||||||||||
| 47 | : d(0), t(Bool) | - | ||||||||||||||||||
| 48 | { | - | ||||||||||||||||||
| 49 | this->b = b; | - | ||||||||||||||||||
| 50 | } executed 7 times by 2 tests: end of blockExecuted by:
| 7 | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | QJsonValue::QJsonValue(double n) | - | ||||||||||||||||||
| 56 | : d(0), t(Double) | - | ||||||||||||||||||
| 57 | { | - | ||||||||||||||||||
| 58 | this->dbl = n; | - | ||||||||||||||||||
| 59 | } executed 8 times by 2 tests: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | QJsonValue::QJsonValue(int n) | - | ||||||||||||||||||
| 66 | : d(0), t(Double) | - | ||||||||||||||||||
| 67 | { | - | ||||||||||||||||||
| 68 | this->dbl = n; | - | ||||||||||||||||||
| 69 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | QJsonValue::QJsonValue(qint64 n) | - | ||||||||||||||||||
| 78 | : d(0), t(Double) | - | ||||||||||||||||||
| 79 | { | - | ||||||||||||||||||
| 80 | this->dbl = double(n); | - | ||||||||||||||||||
| 81 | } never executed: end of block | 0 | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | QJsonValue::QJsonValue(const QString &s) | - | ||||||||||||||||||
| 87 | : d(0), t(String) | - | ||||||||||||||||||
| 88 | { | - | ||||||||||||||||||
| 89 | stringDataFromQStringHelper(s); | - | ||||||||||||||||||
| 90 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 91 | void QJsonValue::stringDataFromQStringHelper(const QString &string) | - | ||||||||||||||||||
| 92 | { | - | ||||||||||||||||||
| 93 | stringData = *(QStringData **)(&string); | - | ||||||||||||||||||
| 94 | stringData->ref.ref(); | - | ||||||||||||||||||
| 95 | } executed 33 times by 3 tests: end of blockExecuted by:
| 33 | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | QJsonValue::QJsonValue(QLatin1String s) | - | ||||||||||||||||||
| 101 | : d(0), t(String) | - | ||||||||||||||||||
| 102 | { | - | ||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | QString str(s); | - | ||||||||||||||||||
| 105 | stringDataFromQStringHelper(str); | - | ||||||||||||||||||
| 106 | } executed 30 times by 2 tests: end of blockExecuted by:
| 30 | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | QJsonValue::QJsonValue(const QJsonArray &a) | - | ||||||||||||||||||
| 112 | : d(a.d), t(Array) | - | ||||||||||||||||||
| 113 | { | - | ||||||||||||||||||
| 114 | base = a.a; | - | ||||||||||||||||||
| 115 | if (d
| 0 | ||||||||||||||||||
| 116 | d->ref.ref(); never executed: d->ref.ref(); | 0 | ||||||||||||||||||
| 117 | } never executed: end of block | 0 | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | QJsonValue::QJsonValue(const QJsonObject &o) | - | ||||||||||||||||||
| 123 | : d(o.d), t(Object) | - | ||||||||||||||||||
| 124 | { | - | ||||||||||||||||||
| 125 | base = o.o; | - | ||||||||||||||||||
| 126 | if (d
| 0 | ||||||||||||||||||
| 127 | d->ref.ref(); never executed: d->ref.ref(); | 0 | ||||||||||||||||||
| 128 | } never executed: end of block | 0 | ||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | QJsonValue::~QJsonValue() | - | ||||||||||||||||||
| 135 | { | - | ||||||||||||||||||
| 136 | if (t == String
| 0-86752 | ||||||||||||||||||
| 137 | free(stringData); executed 1901 times by 40 tests: free(stringData);Executed by:
| 1901 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | if (d
| 0-84142 | ||||||||||||||||||
| 140 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 141 | } executed 156483 times by 118 tests: end of blockExecuted by:
| 156483 | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | QJsonValue::QJsonValue(const QJsonValue &other) | - | ||||||||||||||||||
| 147 | { | - | ||||||||||||||||||
| 148 | t = other.t; | - | ||||||||||||||||||
| 149 | d = other.d; | - | ||||||||||||||||||
| 150 | ui = other.ui; | - | ||||||||||||||||||
| 151 | if (d
| 51-105 | ||||||||||||||||||
| 152 | d->ref.ref(); executed 105 times by 1 test: d->ref.ref();Executed by:
| 105 | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | if (t == String
| 0-139 | ||||||||||||||||||
| 155 | stringData->ref.ref(); executed 17 times by 3 tests: stringData->ref.ref();Executed by:
| 17 | ||||||||||||||||||
| 156 | } executed 156 times by 3 tests: end of blockExecuted by:
| 156 | ||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | QJsonValue &QJsonValue::operator =(const QJsonValue &other) | - | ||||||||||||||||||
| 162 | { | - | ||||||||||||||||||
| 163 | QJsonValue copy(other); | - | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | qSwap(dbl, copy.dbl); | - | ||||||||||||||||||
| 166 | qSwap(d, copy.d); | - | ||||||||||||||||||
| 167 | qSwap(t, copy.t); | - | ||||||||||||||||||
| 168 | return executed 1 time by 1 test: *this;return *this;Executed by:
executed 1 time by 1 test: return *this;Executed by:
| 1 | ||||||||||||||||||
| 169 | } | - | ||||||||||||||||||
| 170 | QJsonValue QJsonValue::fromVariant(const QVariant &variant) | - | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | switch (variant.userType()) { | - | ||||||||||||||||||
| 173 | case never executed: QVariant::Bool:case QVariant::Bool:never executed: case QVariant::Bool: | 0 | ||||||||||||||||||
| 174 | return never executed: QJsonValue(variant.toBool());return QJsonValue(variant.toBool());never executed: return QJsonValue(variant.toBool()); | 0 | ||||||||||||||||||
| 175 | case never executed: QVariant::Int:case QVariant::Int:never executed: case QVariant::Int: | 0 | ||||||||||||||||||
| 176 | case never executed: QMetaType::Float:case QMetaType::Float:never executed: case QMetaType::Float: | 0 | ||||||||||||||||||
| 177 | case never executed: QVariant::Double:case QVariant::Double:never executed: case QVariant::Double: | 0 | ||||||||||||||||||
| 178 | case never executed: QVariant::LongLong:case QVariant::LongLong:never executed: case QVariant::LongLong: | 0 | ||||||||||||||||||
| 179 | case never executed: QVariant::ULongLong:case QVariant::ULongLong:never executed: case QVariant::ULongLong: | 0 | ||||||||||||||||||
| 180 | case never executed: QVariant::UInt:case QVariant::UInt:never executed: case QVariant::UInt: | 0 | ||||||||||||||||||
| 181 | return never executed: QJsonValue(variant.toDouble());return QJsonValue(variant.toDouble());never executed: return QJsonValue(variant.toDouble()); | 0 | ||||||||||||||||||
| 182 | case never executed: QVariant::String:case QVariant::String:never executed: case QVariant::String: | 0 | ||||||||||||||||||
| 183 | return never executed: QJsonValue(variant.toString());return QJsonValue(variant.toString());never executed: return QJsonValue(variant.toString()); | 0 | ||||||||||||||||||
| 184 | case never executed: QVariant::StringList:case QVariant::StringList:never executed: case QVariant::StringList: | 0 | ||||||||||||||||||
| 185 | return never executed: QJsonValue(QJsonArray::fromStringList(variant.toStringList()));return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));never executed: return QJsonValue(QJsonArray::fromStringList(variant.toStringList())); | 0 | ||||||||||||||||||
| 186 | case never executed: QVariant::List:case QVariant::List:never executed: case QVariant::List: | 0 | ||||||||||||||||||
| 187 | return never executed: QJsonValue(QJsonArray::fromVariantList(variant.toList()));return QJsonValue(QJsonArray::fromVariantList(variant.toList()));never executed: return QJsonValue(QJsonArray::fromVariantList(variant.toList())); | 0 | ||||||||||||||||||
| 188 | case never executed: QVariant::Map:case QVariant::Map:never executed: case QVariant::Map: | 0 | ||||||||||||||||||
| 189 | return never executed: QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));never executed: return QJsonValue(QJsonObject::fromVariantMap(variant.toMap())); | 0 | ||||||||||||||||||
| 190 | case never executed: QVariant::Hash:case QVariant::Hash:never executed: case QVariant::Hash: | 0 | ||||||||||||||||||
| 191 | return never executed: QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));return QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));never executed: return QJsonValue(QJsonObject::fromVariantHash(variant.toHash())); | 0 | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | case never executed: QMetaType::QJsonValue:case QMetaType::QJsonValue:never executed: case QMetaType::QJsonValue: | 0 | ||||||||||||||||||
| 194 | return never executed: variant.toJsonValue();return variant.toJsonValue();never executed: return variant.toJsonValue(); | 0 | ||||||||||||||||||
| 195 | case never executed: QMetaType::QJsonObject:case QMetaType::QJsonObject:never executed: case QMetaType::QJsonObject: | 0 | ||||||||||||||||||
| 196 | return never executed: variant.toJsonObject();return variant.toJsonObject();never executed: return variant.toJsonObject(); | 0 | ||||||||||||||||||
| 197 | case never executed: QMetaType::QJsonArray:case QMetaType::QJsonArray:never executed: case QMetaType::QJsonArray: | 0 | ||||||||||||||||||
| 198 | return never executed: variant.toJsonArray();return variant.toJsonArray();never executed: return variant.toJsonArray(); | 0 | ||||||||||||||||||
| 199 | case never executed: QMetaType::QJsonDocument:case QMetaType::QJsonDocument:never executed: {case QMetaType::QJsonDocument: | 0 | ||||||||||||||||||
| 200 | QJsonDocument doc = variant.toJsonDocument(); | - | ||||||||||||||||||
| 201 | return never executed: doc.isArray()return doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object());
never executed: return doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object()); | 0 | ||||||||||||||||||
| 202 | } | - | ||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 205 | break; never executed: break; | 0 | ||||||||||||||||||
| 206 | } | - | ||||||||||||||||||
| 207 | QString string = variant.toString(); | - | ||||||||||||||||||
| 208 | if (string.isEmpty()
| 0 | ||||||||||||||||||
| 209 | return never executed: QJsonValue();return QJsonValue();never executed: return QJsonValue(); | 0 | ||||||||||||||||||
| 210 | return never executed: QJsonValue(string);return QJsonValue(string);never executed: return QJsonValue(string); | 0 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | QVariant QJsonValue::toVariant() const | - | ||||||||||||||||||
| 213 | { | - | ||||||||||||||||||
| 214 | switch (t) { | - | ||||||||||||||||||
| 215 | case never executed: Bool:case Bool:never executed: case Bool: | 0 | ||||||||||||||||||
| 216 | return never executed: b;return b;never executed: return b; | 0 | ||||||||||||||||||
| 217 | case never executed: Double:case Double:never executed: case Double: | 0 | ||||||||||||||||||
| 218 | return never executed: dbl;return dbl;never executed: return dbl; | 0 | ||||||||||||||||||
| 219 | case never executed: String:case String:never executed: case String: | 0 | ||||||||||||||||||
| 220 | return never executed: toString();return toString();never executed: return toString(); | 0 | ||||||||||||||||||
| 221 | case never executed: Array:case Array:never executed: case Array: | 0 | ||||||||||||||||||
| 222 | return never executed: dreturn d ? QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : QVariantList();
never executed: return d ? QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : QVariantList(); | 0 | ||||||||||||||||||
| 223 | QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : never executed: return d ? QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : QVariantList(); | 0 | ||||||||||||||||||
| 224 | QVariantList(); never executed: return d ? QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : QVariantList(); | 0 | ||||||||||||||||||
| 225 | case never executed: Object:case Object:never executed: case Object: | 0 | ||||||||||||||||||
| 226 | return never executed: dreturn d ? QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : QVariantMap();
never executed: return d ? QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : QVariantMap(); | 0 | ||||||||||||||||||
| 227 | QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : never executed: return d ? QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : QVariantMap(); | 0 | ||||||||||||||||||
| 228 | QVariantMap(); never executed: return d ? QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : QVariantMap(); | 0 | ||||||||||||||||||
| 229 | case never executed: Null:case Null:never executed: case Null: | 0 | ||||||||||||||||||
| 230 | case never executed: Undefined:case Undefined:never executed: case Undefined: | 0 | ||||||||||||||||||
| 231 | break; never executed: break; | 0 | ||||||||||||||||||
| 232 | } | - | ||||||||||||||||||
| 233 | return never executed: QVariant();return QVariant();never executed: return QVariant(); | 0 | ||||||||||||||||||
| 234 | } | - | ||||||||||||||||||
| 235 | QJsonValue::Type QJsonValue::type() const | - | ||||||||||||||||||
| 236 | { | - | ||||||||||||||||||
| 237 | return executed 272 times by 3 tests: t;return t;Executed by:
executed 272 times by 3 tests: return t;Executed by:
| 272 | ||||||||||||||||||
| 238 | } | - | ||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | bool QJsonValue::toBool(bool defaultValue) const | - | ||||||||||||||||||
| 246 | { | - | ||||||||||||||||||
| 247 | if (t != Bool
| 0-657 | ||||||||||||||||||
| 248 | return never executed: defaultValue;return defaultValue;never executed: return defaultValue; | 0 | ||||||||||||||||||
| 249 | return executed 657 times by 112 tests: b;return b;Executed by:
executed 657 times by 112 tests: return b;Executed by:
| 657 | ||||||||||||||||||
| 250 | } | - | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | int QJsonValue::toInt(int defaultValue) const | - | ||||||||||||||||||
| 259 | { | - | ||||||||||||||||||
| 260 | if (t == Double
| 0 | ||||||||||||||||||
| 261 | return never executed: int(dbl);return int(dbl);never executed: return int(dbl); | 0 | ||||||||||||||||||
| 262 | return never executed: defaultValue;return defaultValue;never executed: return defaultValue; | 0 | ||||||||||||||||||
| 263 | } | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | double QJsonValue::toDouble(double defaultValue) const | - | ||||||||||||||||||
| 271 | { | - | ||||||||||||||||||
| 272 | if (t != Double
| 2-1583 | ||||||||||||||||||
| 273 | return executed 2 times by 1 test: defaultValue;return defaultValue;Executed by:
executed 2 times by 1 test: return defaultValue;Executed by:
| 2 | ||||||||||||||||||
| 274 | return executed 1583 times by 114 tests: dbl;return dbl;Executed by:
executed 1583 times by 114 tests: return dbl;Executed by:
| 1583 | ||||||||||||||||||
| 275 | } | - | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | QString QJsonValue::toString(const QString &defaultValue) const | - | ||||||||||||||||||
| 283 | { | - | ||||||||||||||||||
| 284 | if (t != String
| 157-69716 | ||||||||||||||||||
| 285 | return executed 157 times by 3 tests: defaultValue;return defaultValue;Executed by:
executed 157 times by 3 tests: return defaultValue;Executed by:
| 157 | ||||||||||||||||||
| 286 | stringData->ref.ref(); | - | ||||||||||||||||||
| 287 | QStringDataPtr holder = { stringData }; | - | ||||||||||||||||||
| 288 | return executed 69716 times by 116 tests: QString(holder);return QString(holder);Executed by:
executed 69716 times by 116 tests: return QString(holder);Executed by:
| 69716 | ||||||||||||||||||
| 289 | } | - | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | QJsonArray QJsonValue::toArray(const QJsonArray &defaultValue) const | - | ||||||||||||||||||
| 297 | { | - | ||||||||||||||||||
| 298 | if (!d
| 0-41984 | ||||||||||||||||||
| 299 | return executed 42 times by 2 tests: defaultValue;return defaultValue;Executed by:
executed 42 times by 2 tests: return defaultValue;Executed by:
| 42 | ||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | return executed 41984 times by 113 tests: QJsonArray(d, static_cast<QJsonPrivate::Array *>(base));return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base));Executed by:
executed 41984 times by 113 tests: return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base));Executed by:
| 41984 | ||||||||||||||||||
| 302 | } | - | ||||||||||||||||||
| 303 | QJsonArray QJsonValue::toArray() const | - | ||||||||||||||||||
| 304 | { | - | ||||||||||||||||||
| 305 | return executed 42026 times by 114 tests: toArray(QJsonArray());return toArray(QJsonArray());Executed by:
executed 42026 times by 114 tests: return toArray(QJsonArray());Executed by:
| 42026 | ||||||||||||||||||
| 306 | } | - | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | QJsonObject QJsonValue::toObject(const QJsonObject &defaultValue) const | - | ||||||||||||||||||
| 314 | { | - | ||||||||||||||||||
| 315 | if (!d
| 0-42003 | ||||||||||||||||||
| 316 | return never executed: defaultValue;return defaultValue;never executed: return defaultValue; | 0 | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | return executed 42003 times by 114 tests: QJsonObject(d, static_cast<QJsonPrivate::Object *>(base));return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base));Executed by:
executed 42003 times by 114 tests: return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base));Executed by:
| 42003 | ||||||||||||||||||
| 319 | } | - | ||||||||||||||||||
| 320 | QJsonObject QJsonValue::toObject() const | - | ||||||||||||||||||
| 321 | { | - | ||||||||||||||||||
| 322 | return executed 42003 times by 114 tests: toObject(QJsonObject());return toObject(QJsonObject());Executed by:
executed 42003 times by 114 tests: return toObject(QJsonObject());Executed by:
| 42003 | ||||||||||||||||||
| 323 | } | - | ||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | bool QJsonValue::operator==(const QJsonValue &other) const | - | ||||||||||||||||||
| 329 | { | - | ||||||||||||||||||
| 330 | if (t != other.t
| 0-34 | ||||||||||||||||||
| 331 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | switch (t) { | - | ||||||||||||||||||
| 334 | case never executed: Undefined:case Undefined:never executed: case Undefined: | 0 | ||||||||||||||||||
| 335 | case executed 4 times by 1 test: Null:case Null:Executed by:
executed 4 times by 1 test: case Null:Executed by:
| 4 | ||||||||||||||||||
| 336 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||
| 337 | case never executed: Bool:case Bool:never executed: case Bool: | 0 | ||||||||||||||||||
| 338 | return never executed: b == other.b;return b == other.b;never executed: return b == other.b; | 0 | ||||||||||||||||||
| 339 | case executed 4 times by 1 test: Double:case Double:Executed by:
executed 4 times by 1 test: case Double:Executed by:
| 4 | ||||||||||||||||||
| 340 | return executed 4 times by 1 test: dbl == other.dbl;return dbl == other.dbl;Executed by:
executed 4 times by 1 test: return dbl == other.dbl;Executed by:
| 4 | ||||||||||||||||||
| 341 | case executed 26 times by 1 test: String:case String:Executed by:
executed 26 times by 1 test: case String:Executed by:
| 26 | ||||||||||||||||||
| 342 | return executed 26 times by 1 test: toString() == other.toString();return toString() == other.toString();Executed by:
executed 26 times by 1 test: return toString() == other.toString();Executed by:
| 26 | ||||||||||||||||||
| 343 | case never executed: Array:case Array:never executed: case Array: | 0 | ||||||||||||||||||
| 344 | if (base == other.base
| 0 | ||||||||||||||||||
| 345 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 346 | if (!base
| 0 | ||||||||||||||||||
| 347 | return never executed: !other.base->length;return !other.base->length;never executed: return !other.base->length; | 0 | ||||||||||||||||||
| 348 | if (!other.base
| 0 | ||||||||||||||||||
| 349 | return never executed: !base->length;return !base->length;never executed: return !base->length; | 0 | ||||||||||||||||||
| 350 | return never executed: QJsonArray(d, static_cast<QJsonPrivate::Array *>(base))return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)) == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base));never executed: return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)) == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base)); | 0 | ||||||||||||||||||
| 351 | == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base)); never executed: return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)) == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base)); | 0 | ||||||||||||||||||
| 352 | case never executed: Object:case Object:never executed: case Object: | 0 | ||||||||||||||||||
| 353 | if (base == other.base
| 0 | ||||||||||||||||||
| 354 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 355 | if (!base
| 0 | ||||||||||||||||||
| 356 | return never executed: !other.base->length;return !other.base->length;never executed: return !other.base->length; | 0 | ||||||||||||||||||
| 357 | if (!other.base
| 0 | ||||||||||||||||||
| 358 | return never executed: !base->length;return !base->length;never executed: return !base->length; | 0 | ||||||||||||||||||
| 359 | return never executed: QJsonObject(d, static_cast<QJsonPrivate::Object *>(base))return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)) == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base));never executed: return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)) == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base)); | 0 | ||||||||||||||||||
| 360 | == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base)); never executed: return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)) == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base)); | 0 | ||||||||||||||||||
| 361 | } | - | ||||||||||||||||||
| 362 | return executed 4 times by 1 test: true;return true;Executed by:
executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||||||||
| 363 | } | - | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | bool QJsonValue::operator!=(const QJsonValue &other) const | - | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 | return executed 26 times by 1 test: !(*this == other);return !(*this == other);Executed by:
executed 26 times by 1 test: return !(*this == other);Executed by:
| 26 | ||||||||||||||||||
| 371 | } | - | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | void QJsonValue::detach() | - | ||||||||||||||||||
| 377 | { | - | ||||||||||||||||||
| 378 | if (!d
| 0 | ||||||||||||||||||
| 379 | return; never executed: return; | 0 | ||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | QJsonPrivate::Data *x = d->clone(base); | - | ||||||||||||||||||
| 382 | x->ref.ref(); | - | ||||||||||||||||||
| 383 | if (!d->ref.deref()
| 0 | ||||||||||||||||||
| 384 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 385 | d = x; | - | ||||||||||||||||||
| 386 | base = static_cast<QJsonPrivate::Object *>(d->header->root()); | - | ||||||||||||||||||
| 387 | } never executed: end of block | 0 | ||||||||||||||||||
| 388 | QJsonValueRef &QJsonValueRef::operator =(const QJsonValue &val) | - | ||||||||||||||||||
| 389 | { | - | ||||||||||||||||||
| 390 | if (is_object
| 0 | ||||||||||||||||||
| 391 | o->setValueAt(index, val); never executed: o->setValueAt(index, val); | 0 | ||||||||||||||||||
| 392 | else | - | ||||||||||||||||||
| 393 | a->replace(index, val); never executed: a->replace(index, val); | 0 | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||
| 396 | } | - | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | QJsonValueRef &QJsonValueRef::operator =(const QJsonValueRef &ref) | - | ||||||||||||||||||
| 399 | { | - | ||||||||||||||||||
| 400 | if (is_object
| 0 | ||||||||||||||||||
| 401 | o->setValueAt(index, ref); never executed: o->setValueAt(index, ref); | 0 | ||||||||||||||||||
| 402 | else | - | ||||||||||||||||||
| 403 | a->replace(index, ref); never executed: a->replace(index, ref); | 0 | ||||||||||||||||||
| 404 | - | |||||||||||||||||||
| 405 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||
| 406 | } | - | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | QVariant QJsonValueRef::toVariant() const | - | ||||||||||||||||||
| 409 | { | - | ||||||||||||||||||
| 410 | return never executed: toValue().toVariant();return toValue().toVariant();never executed: return toValue().toVariant(); | 0 | ||||||||||||||||||
| 411 | } | - | ||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | QJsonArray QJsonValueRef::toArray() const | - | ||||||||||||||||||
| 414 | { | - | ||||||||||||||||||
| 415 | return never executed: toValue().toArray();return toValue().toArray();never executed: return toValue().toArray(); | 0 | ||||||||||||||||||
| 416 | } | - | ||||||||||||||||||
| 417 | - | |||||||||||||||||||
| 418 | QJsonObject QJsonValueRef::toObject() const | - | ||||||||||||||||||
| 419 | { | - | ||||||||||||||||||
| 420 | return never executed: toValue().toObject();return toValue().toObject();never executed: return toValue().toObject(); | 0 | ||||||||||||||||||
| 421 | } | - | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | QJsonValue QJsonValueRef::toValue() const | - | ||||||||||||||||||
| 424 | { | - | ||||||||||||||||||
| 425 | if (!is_object
| 0 | ||||||||||||||||||
| 426 | return never executed: a->at(index);return a->at(index);never executed: return a->at(index); | 0 | ||||||||||||||||||
| 427 | return never executed: o->valueAt(index);return o->valueAt(index);never executed: return o->valueAt(index); | 0 | ||||||||||||||||||
| 428 | } | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | QDebug operator<<(QDebug dbg, const QJsonValue &o) | - | ||||||||||||||||||
| 432 | { | - | ||||||||||||||||||
| 433 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||
| 434 | switch (o.t) { | - | ||||||||||||||||||
| 435 | case never executed: QJsonValue::Undefined:case QJsonValue::Undefined:never executed: case QJsonValue::Undefined: | 0 | ||||||||||||||||||
| 436 | dbg << "QJsonValue(undefined)"; | - | ||||||||||||||||||
| 437 | break; never executed: break; | 0 | ||||||||||||||||||
| 438 | case executed 1 time by 1 test: QJsonValue::Null:case QJsonValue::Null:Executed by:
executed 1 time by 1 test: case QJsonValue::Null:Executed by:
| 1 | ||||||||||||||||||
| 439 | dbg << "QJsonValue(null)"; | - | ||||||||||||||||||
| 440 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||
| 441 | case never executed: QJsonValue::Bool:case QJsonValue::Bool:never executed: case QJsonValue::Bool: | 0 | ||||||||||||||||||
| 442 | dbg.nospace() << "QJsonValue(bool, " << o.toBool() << ')'; | - | ||||||||||||||||||
| 443 | break; never executed: break; | 0 | ||||||||||||||||||
| 444 | case never executed: QJsonValue::Double:case QJsonValue::Double:never executed: case QJsonValue::Double: | 0 | ||||||||||||||||||
| 445 | dbg.nospace() << "QJsonValue(double, " << o.toDouble() << ')'; | - | ||||||||||||||||||
| 446 | break; never executed: break; | 0 | ||||||||||||||||||
| 447 | case never executed: QJsonValue::String:case QJsonValue::String:never executed: case QJsonValue::String: | 0 | ||||||||||||||||||
| 448 | dbg.nospace() << "QJsonValue(string, " << o.toString() << ')'; | - | ||||||||||||||||||
| 449 | break; never executed: break; | 0 | ||||||||||||||||||
| 450 | case never executed: QJsonValue::Array:case QJsonValue::Array:never executed: case QJsonValue::Array: | 0 | ||||||||||||||||||
| 451 | dbg.nospace() << "QJsonValue(array, "; | - | ||||||||||||||||||
| 452 | dbg << o.toArray(); | - | ||||||||||||||||||
| 453 | dbg << ')'; | - | ||||||||||||||||||
| 454 | break; never executed: break; | 0 | ||||||||||||||||||
| 455 | case never executed: QJsonValue::Object:case QJsonValue::Object:never executed: case QJsonValue::Object: | 0 | ||||||||||||||||||
| 456 | dbg.nospace() << "QJsonValue(object, "; | - | ||||||||||||||||||
| 457 | dbg << o.toObject(); | - | ||||||||||||||||||
| 458 | dbg << ')'; | - | ||||||||||||||||||
| 459 | break; never executed: break; | 0 | ||||||||||||||||||
| 460 | } | - | ||||||||||||||||||
| 461 | return executed 1 time by 1 test: dbg;return dbg;Executed by:
executed 1 time by 1 test: return dbg;Executed by:
| 1 | ||||||||||||||||||
| 462 | } | - | ||||||||||||||||||
| 463 | - | |||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |