OpenCoverage

qjsonarray.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/json/qjsonarray.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4QJsonArray::QJsonArray()-
5 : d(0), a(0)-
6{-
7}
executed 42110 times by 117 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
42110
8QJsonArray::QJsonArray(QJsonPrivate::Data *data, QJsonPrivate::Array *array)-
9 : d(data), a(array)-
10{-
11 ((!(data)) ? qt_assert("data",__FILE__,157) : qt_noop());-
12 ((!(array)) ? qt_assert("array",__FILE__,158) : qt_noop());-
13 d->ref.ref();-
14}
executed 42001 times by 114 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
42001
15void QJsonArray::initialize()-
16{-
17 d = 0;-
18 a = 0;-
19}
never executed: end of block
0
20-
21-
22-
23-
24QJsonArray::~QJsonArray()-
25{-
26 if (d
dDescription
TRUEevaluated 42449 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
FALSEevaluated 42148 times by 117 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
&& !d->ref.deref()
!d->ref.deref()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 42447 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
)
2-42449
27 delete d;
executed 2 times by 1 test: delete d;
Executed by:
  • tst_QMetaType
2
28}
executed 84597 times by 117 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
84597
29-
30-
31-
32-
33-
34-
35-
36QJsonArray::QJsonArray(const QJsonArray &other)-
37{-
38 d = other.d;-
39 a = other.a;-
40 if (d
dDescription
TRUEevaluated 441 times by 2 tests
Evaluated by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
FALSEevaluated 45 times by 3 tests
Evaluated by:
  • tst_QFactoryLoader
  • tst_QOpenGlConfig
  • tst_QVariant
)
45-441
41 d->ref.ref();
executed 441 times by 2 tests: d->ref.ref();
Executed by:
  • tst_QMetaType
  • tst_QNetworkCookieJar
441
42}
executed 486 times by 5 tests: end of block
Executed by:
  • tst_QFactoryLoader
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_QVariant
486
43-
44-
45-
46-
47QJsonArray &QJsonArray::operator =(const QJsonArray &other)-
48{-
49 if (d != other.d
d != other.dDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
FALSEevaluated 41 times by 2 tests
Evaluated by:
  • tst_QOpenGlConfig
  • tst_QVariant
) {
5-41
50 if (d
dDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
&& !d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0-5
51 delete d;
never executed: delete d;
0
52 d = other.d;-
53 if (d
dDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
FALSEnever evaluated
)
0-5
54 d->ref.ref();
executed 5 times by 1 test: d->ref.ref();
Executed by:
  • tst_QOpenGlConfig
5
55 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QOpenGlConfig
5
56 a = other.a;-
57-
58 return
executed 46 times by 2 tests: return *this;
Executed by:
  • tst_QOpenGlConfig
  • tst_QVariant
*this;
executed 46 times by 2 tests: return *this;
Executed by:
  • tst_QOpenGlConfig
  • tst_QVariant
46
59}-
60QJsonArray QJsonArray::fromStringList(const QStringList &list)-
61{-
62 QJsonArray array;-
63 for (QStringList::const_iterator it = list.constBegin(); it != list.constEnd()
it != list.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
64 array.append(QJsonValue(*it));
never executed: array.append(QJsonValue(*it));
0
65 return
never executed: return array;
array;
never executed: return array;
0
66}-
67QJsonArray QJsonArray::fromVariantList(const QVariantList &list)-
68{-
69 QJsonArray array;-
70 if (list.isEmpty()
list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
71 return
never executed: return array;
array;
never executed: return array;
0
72-
73 array.detach2(1024);-
74-
75 QVector<QJsonPrivate::Value> values;-
76 values.resize(list.size());-
77 QJsonPrivate::Value *valueData = values.data();-
78 uint currentOffset = sizeof(QJsonPrivate::Base);-
79-
80 for (int i = 0; i < list.size()
i < list.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
81 QJsonValue val = QJsonValue::fromVariant(list.at(i));-
82-
83 bool latinOrIntValue;-
84 int valueSize = QJsonPrivate::Value::requiredStorage(val, &latinOrIntValue);-
85-
86 if (!array.detach2(valueSize)
!array.detach2(valueSize)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
87 return
never executed: return QJsonArray();
QJsonArray();
never executed: return QJsonArray();
0
88-
89 QJsonPrivate::Value *v = valueData + i;-
90 v->type = (val.t == QJsonValue::Undefined
val.t == QJsonValue::UndefinedDescription
TRUEnever evaluated
FALSEnever evaluated
? QJsonValue::Null : val.t);
0
91 v->latinOrIntValue = latinOrIntValue;-
92 v->latinKey = false;-
93 v->value = QJsonPrivate::Value::valueToStore(val, currentOffset);-
94 if (valueSize
valueSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
95 QJsonPrivate::Value::copyData(val, (char *)array.a + currentOffset, latinOrIntValue);
never executed: QJsonPrivate::Value::copyData(val, (char *)array.a + currentOffset, latinOrIntValue);
0
96-
97 currentOffset += valueSize;-
98 array.a->size = currentOffset;-
99 }
never executed: end of block
0
100-
101-
102 array.a->tableOffset = currentOffset;-
103 if (!array.detach2(sizeof(QJsonPrivate::offset)*values.size())
!array.detach2...values.size())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
104 return
never executed: return QJsonArray();
QJsonArray();
never executed: return QJsonArray();
0
105 memcpy(array.a->table(), values.constData(), values.size()*sizeof(uint));-
106 array.a->length = values.size();-
107 array.a->size = currentOffset + sizeof(QJsonPrivate::offset)*values.size();-
108-
109 return
never executed: return array;
array;
never executed: return array;
0
110}-
111-
112-
113-
114-
115-
116-
117QVariantList QJsonArray::toVariantList() const-
118{-
119 QVariantList list;-
120-
121 if (a
aDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
122 list.reserve(a->length);-
123 for (int i = 0; i < (int)a->length
i < (int)a->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
124 list.append(QJsonValue(d, a, a->at(i)).toVariant());
never executed: list.append(QJsonValue(d, a, a->at(i)).toVariant());
0
125 }
never executed: end of block
0
126 return
never executed: return list;
list;
never executed: return list;
0
127}-
128-
129-
130-
131-
132-
133int QJsonArray::size() const-
134{-
135 if (!d
!dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFactoryLoader
FALSEevaluated 42948 times by 114 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
)
2-42948
136 return
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QFactoryLoader
0;
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QFactoryLoader
2
137-
138 return
executed 42948 times by 114 tests: return (int)a->length;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
(int)a->length;
executed 42948 times by 114 tests: return (int)a->length;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
42948
139}-
140bool QJsonArray::isEmpty() const-
141{-
142 if (!d
!dDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
)
3-18
143 return
executed 18 times by 1 test: return true;
Executed by:
  • tst_QOpenGlConfig
true;
executed 18 times by 1 test: return true;
Executed by:
  • tst_QOpenGlConfig
18
144-
145 return
executed 3 times by 1 test: return !a->length;
Executed by:
  • tst_QOpenGlConfig
!a->length;
executed 3 times by 1 test: return !a->length;
Executed by:
  • tst_QOpenGlConfig
3
146}-
147-
148-
149-
150-
151-
152-
153-
154QJsonValue QJsonArray::at(int i) const-
155{-
156 if (!a
!aDescription
TRUEnever evaluated
FALSEevaluated 68845 times by 114 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
|| i < 0
i < 0Description
TRUEnever evaluated
FALSEevaluated 68845 times by 114 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
|| i >= (int)a->length
i >= (int)a->lengthDescription
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QImageReader
  • tst_QImageWriter
FALSEevaluated 68843 times by 114 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
)
0-68845
157 return
executed 2 times by 2 tests: return QJsonValue(QJsonValue::Undefined);
Executed by:
  • tst_QImageReader
  • tst_QImageWriter
QJsonValue(QJsonValue::Undefined);
executed 2 times by 2 tests: return QJsonValue(QJsonValue::Undefined);
Executed by:
  • tst_QImageReader
  • tst_QImageWriter
2
158-
159 return
executed 68843 times by 114 tests: return QJsonValue(d, a, a->at(i));
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
QJsonValue(d, a, a->at(i));
executed 68843 times by 114 tests: return QJsonValue(d, a, a->at(i));
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
68843
160}-
161QJsonValue QJsonArray::first() const-
162{-
163 return
never executed: return at(0);
at(0);
never executed: return at(0);
0
164}-
165QJsonValue QJsonArray::last() const-
166{-
167 return
never executed: return at(a ? (a->length - 1) : 0);
at(a ? (a->length - 1) : 0);
never executed: return at(a ? (a->length - 1) : 0);
0
168}-
169void QJsonArray::prepend(const QJsonValue &value)-
170{-
171 insert(0, value);-
172}
never executed: end of block
0
173-
174-
175-
176-
177-
178-
179void QJsonArray::append(const QJsonValue &value)-
180{-
181 insert(a ? (int)a->length : 0, value);-
182}
executed 8 times by 1 test: end of block
Executed by:
  • tst_QMetaType
8
183-
184-
185-
186-
187-
188-
189-
190void QJsonArray::removeAt(int i)-
191{-
192 if (!a
!aDescription
TRUEnever evaluated
FALSEnever evaluated
|| i < 0
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| i >= (int)a->length
i >= (int)a->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
193 return;
never executed: return;
0
194-
195 detach2();-
196 a->removeItems(i, 1);-
197 ++d->compactionCounter;-
198 if (d->compactionCounter > 32u
d->compactionCounter > 32uDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->compactionCounter >= unsigned(a->length) / 2u
d->compactionC...->length) / 2uDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
199 compact();
never executed: compact();
0
200}
never executed: end of block
0
201QJsonValue QJsonArray::takeAt(int i)-
202{-
203 if (!a
!aDescription
TRUEnever evaluated
FALSEnever evaluated
|| i < 0
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| i >= (int)a->length
i >= (int)a->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
204 return
never executed: return QJsonValue(QJsonValue::Undefined);
QJsonValue(QJsonValue::Undefined);
never executed: return QJsonValue(QJsonValue::Undefined);
0
205-
206 QJsonValue v(d, a, a->at(i));-
207 removeAt(i);-
208 return
never executed: return v;
v;
never executed: return v;
0
209}-
210void QJsonArray::insert(int i, const QJsonValue &value)-
211{-
212 ((!(i >= 0 && i <= (a ? (int)a->length : 0))) ? qt_assert("i >= 0 && i <= (a ? (int)a->length : 0)",__FILE__,482) : qt_noop());-
213 QJsonValue val = value;-
214-
215 bool compressed;-
216 int valueSize = QJsonPrivate::Value::requiredStorage(val, &compressed);-
217-
218 if (!detach2(valueSize + sizeof(QJsonPrivate::Value))
!detach2(value...ivate::Value))Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
)
0-8
219 return;
never executed: return;
0
220-
221 if (!a->length
!a->lengthDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
)
2-6
222 a->tableOffset = sizeof(QJsonPrivate::Array);
executed 2 times by 1 test: a->tableOffset = sizeof(QJsonPrivate::Array);
Executed by:
  • tst_QMetaType
2
223-
224 int valueOffset = a->reserveSpace(valueSize, i, 1, false);-
225 if (!valueOffset
!valueOffsetDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
)
0-8
226 return;
never executed: return;
0
227-
228 QJsonPrivate::Value &v = (*a)[i];-
229 v.type = (val.t == QJsonValue::Undefined
val.t == QJsonValue::UndefinedDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
? QJsonValue::Null : val.t);
0-8
230 v.latinOrIntValue = compressed;-
231 v.latinKey = false;-
232 v.value = QJsonPrivate::Value::valueToStore(val, valueOffset);-
233 if (valueSize
valueSizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
)
2-6
234 QJsonPrivate::Value::copyData(val, (char *)a + valueOffset, compressed);
executed 2 times by 1 test: QJsonPrivate::Value::copyData(val, (char *)a + valueOffset, compressed);
Executed by:
  • tst_QMetaType
2
235}
executed 8 times by 1 test: end of block
Executed by:
  • tst_QMetaType
8
236void QJsonArray::replace(int i, const QJsonValue &value)-
237{-
238 ((!(a && i >= 0 && i < (int)(a->length))) ? qt_assert("a && i >= 0 && i < (int)(a->length)",__FILE__,533) : qt_noop());-
239 QJsonValue val = value;-
240-
241 bool compressed;-
242 int valueSize = QJsonPrivate::Value::requiredStorage(val, &compressed);-
243-
244 if (!detach2(valueSize)
!detach2(valueSize)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
245 return;
never executed: return;
0
246-
247 if (!a->length
!a->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
248 a->tableOffset = sizeof(QJsonPrivate::Array);
never executed: a->tableOffset = sizeof(QJsonPrivate::Array);
0
249-
250 int valueOffset = a->reserveSpace(valueSize, i, 1, true);-
251 if (!valueOffset
!valueOffsetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
252 return;
never executed: return;
0
253-
254 QJsonPrivate::Value &v = (*a)[i];-
255 v.type = (val.t == QJsonValue::Undefined
val.t == QJsonValue::UndefinedDescription
TRUEnever evaluated
FALSEnever evaluated
? QJsonValue::Null : val.t);
0
256 v.latinOrIntValue = compressed;-
257 v.latinKey = false;-
258 v.value = QJsonPrivate::Value::valueToStore(val, valueOffset);-
259 if (valueSize
valueSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
260 QJsonPrivate::Value::copyData(val, (char *)a + valueOffset, compressed);
never executed: QJsonPrivate::Value::copyData(val, (char *)a + valueOffset, compressed);
0
261-
262 ++d->compactionCounter;-
263 if (d->compactionCounter > 32u
d->compactionCounter > 32uDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->compactionCounter >= unsigned(a->length) / 2u
d->compactionC...->length) / 2uDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
264 compact();
never executed: compact();
0
265}
never executed: end of block
0
266-
267-
268-
269-
270-
271-
272bool QJsonArray::contains(const QJsonValue &value) const-
273{-
274 for (int i = 0; i < size()
i < size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
275 if (at(i) == value
at(i) == valueDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
276 return
never executed: return true;
true;
never executed: return true;
0
277 }
never executed: end of block
0
278 return
never executed: return false;
false;
never executed: return false;
0
279}-
280QJsonValueRef QJsonArray::operator [](int i)-
281{-
282 ((!(a && i >= 0 && i < (int)a->length)) ? qt_assert("a && i >= 0 && i < (int)a->length",__FILE__,591) : qt_noop());-
283 return
never executed: return QJsonValueRef(this, i);
QJsonValueRef(this, i);
never executed: return QJsonValueRef(this, i);
0
284}-
285-
286-
287-
288-
289-
290-
291QJsonValue QJsonArray::operator[](int i) const-
292{-
293 return
never executed: return at(i);
at(i);
never executed: return at(i);
0
294}-
295-
296-
297-
298-
299bool QJsonArray::operator==(const QJsonArray &other) const-
300{-
301 if (a == other.a
a == other.aDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEnever evaluated
)
0-8
302 return
executed 8 times by 1 test: return true;
Executed by:
  • tst_QMetaType
true;
executed 8 times by 1 test: return true;
Executed by:
  • tst_QMetaType
8
303-
304 if (!a
!aDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
305 return
never executed: return !other.a->length;
!other.a->length;
never executed: return !other.a->length;
0
306 if (!other.a
!other.aDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
307 return
never executed: return !a->length;
!a->length;
never executed: return !a->length;
0
308 if (a->length != other.a->length
a->length != other.a->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
309 return
never executed: return false;
false;
never executed: return false;
0
310-
311 for (int i = 0; i < (int)a->length
i < (int)a->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
312 if (QJsonValue(d, a, a->at(i)) != QJsonValue(other.d, other.a, other.a->at(i))
QJsonValue(d, ...ther.a->at(i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
313 return
never executed: return false;
false;
never executed: return false;
0
314 }
never executed: end of block
0
315 return
never executed: return true;
true;
never executed: return true;
0
316}-
317-
318-
319-
320-
321bool QJsonArray::operator!=(const QJsonArray &other) const-
322{-
323 return
never executed: return !(*this == other);
!(*this == other);
never executed: return !(*this == other);
0
324}-
325void QJsonArray::detach(uint reserve)-
326{-
327 (void)reserve;-
328 ((!(!reserve)) ? qt_assert("!reserve",__FILE__,1172) : qt_noop());-
329 detach2(0);-
330}
never executed: end of block
0
331-
332-
333-
334-
335bool QJsonArray::detach2(uint reserve)-
336{-
337 if (!d
!dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
) {
2-6
338 if (reserve >= QJsonPrivate::Value::MaxSize
reserve >= QJs...Value::MaxSizeDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
) {
0-2
339 QMessageLogger(__FILE__, 1183, __PRETTY_FUNCTION__).warning("QJson: Document too large to store in data structure");-
340 return
never executed: return false;
false;
never executed: return false;
0
341 }-
342 d = new QJsonPrivate::Data(reserve, QJsonValue::Array);-
343 a = static_cast<QJsonPrivate::Array *>(d->header->root());-
344 d->ref.ref();-
345 return
executed 2 times by 1 test: return true;
Executed by:
  • tst_QMetaType
true;
executed 2 times by 1 test: return true;
Executed by:
  • tst_QMetaType
2
346 }-
347 if (reserve == 0
reserve == 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
&& d->ref.load() == 1
d->ref.load() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0-6
348 return
never executed: return true;
true;
never executed: return true;
0
349-
350 QJsonPrivate::Data *x = d->clone(a, reserve);-
351 if (!x
!xDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
)
0-6
352 return
never executed: return false;
false;
never executed: return false;
0
353 x->ref.ref();-
354 if (!d->ref.deref()
!d->ref.deref()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMetaType
)
2-4
355 delete d;
executed 2 times by 1 test: delete d;
Executed by:
  • tst_QMetaType
2
356 d = x;-
357 a = static_cast<QJsonPrivate::Array *>(d->header->root());-
358 return
executed 6 times by 1 test: return true;
Executed by:
  • tst_QMetaType
true;
executed 6 times by 1 test: return true;
Executed by:
  • tst_QMetaType
6
359}-
360-
361-
362-
363-
364void QJsonArray::compact()-
365{-
366 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->compactionCounter
!d->compactionCounterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
367 return;
never executed: return;
0
368-
369 detach2();-
370 d->compact();-
371 a = static_cast<QJsonPrivate::Array *>(d->header->root());-
372}
never executed: end of block
0
373-
374-
375-
376QDebug operator<<(QDebug dbg, const QJsonArray &a)-
377{-
378 QDebugStateSaver saver(dbg);-
379 if (!a.a
!a.aDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QVariant
FALSEnever evaluated
) {
0-1
380 dbg << "QJsonArray()";-
381 return
executed 1 time by 1 test: return dbg;
Executed by:
  • tst_QVariant
dbg;
executed 1 time by 1 test: return dbg;
Executed by:
  • tst_QVariant
1
382 }-
383 QByteArray json;-
384 QJsonPrivate::Writer::arrayToJson(a.a, json, 0, true);-
385 dbg.nospace() << "QJsonArray("-
386 << json.constData()-
387 << ")";-
388 return
never executed: return dbg;
dbg;
never executed: return dbg;
0
389}-
390-
391-
392-
Switch to Source codePreprocessed file

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