aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp
blob: 28f24be0cccef70130fffb5d7247c912987e85ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include <QString>
#include <QtTest>

class BenchTest : public QObject
{
    Q_OBJECT

public:
    BenchTest();

private Q_SLOTS:
    void testCase1();
    void testCase1_data();
};

BenchTest::BenchTest()
{
}

void BenchTest::testCase1()
{
    QFETCH(bool, localAware);

    QString str1 = QLatin1String("Hello World");
    QString str2 = QLatin1String("Hallo Welt");
    if (!localAware) {
        QBENCHMARK {
            str1 == str2;
        }
    } else {
        QBENCHMARK {
            str1.localeAwareCompare(str2) == 0;
        }
    }
}

void BenchTest::testCase1_data()
{
    QTest::addColumn<bool>("localAware");
    QTest::newRow("localAware") << true;
    QTest::newRow("simple") << false;
}

QTEST_MAIN(BenchTest)

#include "tst_benchtest.moc"