summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp')
-rw-r--r--tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp b/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp
index 05e20645d7..a97cba7c50 100644
--- a/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp
+++ b/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp
@@ -1,6 +1,6 @@
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2016 Intel Corporation.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDebug>
#include <QIODevice>
#include <QFile>
@@ -31,6 +31,9 @@ private slots:
void toPercentEncoding_data();
void toPercentEncoding();
+
+ void operator_assign_char();
+ void operator_assign_char_data();
};
void tst_QByteArray::initTestCase()
@@ -353,6 +356,38 @@ void tst_QByteArray::toPercentEncoding()
QTEST(encoded, "expected");
}
+void tst_QByteArray::operator_assign_char()
+{
+ QFETCH(QByteArray, data);
+ QString str(data.size(), Qt::Uninitialized);
+
+ const char *tdata = data.constData();
+ QBENCHMARK {
+ str.operator=(tdata);
+ }
+}
+
+void tst_QByteArray::operator_assign_char_data()
+{
+ QTest::addColumn<QByteArray>("data");
+
+ QByteArray data;
+ data.fill('a', 5);
+ QTest::newRow("length: 5") << data;
+ data.fill('b', 10);
+ QTest::newRow("length: 10") << data;
+ data.fill('c', 20);
+ QTest::newRow("length: 20") << data;
+ data.fill('d', 50);
+ QTest::newRow("length: 50") << data;
+ data.fill('e', 100);
+ QTest::newRow("length: 100") << data;
+ data.fill('f', 500);
+ QTest::newRow("length: 500") << data;
+ data.fill('g', 1'000);
+ QTest::newRow("length: 1'000") << data;
+}
+
QTEST_MAIN(tst_QByteArray)
#include "tst_bench_qbytearray.moc"