diff options
Diffstat (limited to 'tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp')
-rw-r--r-- | tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp b/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp index a98503210c..a97cba7c50 100644 --- a/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp +++ b/tests/benchmarks/corelib/text/qbytearray/tst_bench_qbytearray.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <QIODevice> #include <QFile> @@ -56,6 +31,9 @@ private slots: void toPercentEncoding_data(); void toPercentEncoding(); + + void operator_assign_char(); + void operator_assign_char_data(); }; void tst_QByteArray::initTestCase() @@ -378,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" |