summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qstringbuilder/qstringbuilder1
Commit message (Collapse)AuthorAgeFilesLines
* Change license for tests filesLucie Gérard2024-02-042-2/+2
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* tst_QStringBuilder: update the warning re:includes in stringbuilder.cppMarc Mutz2023-09-201-2/+2
| | | | | | | | | | | Not only are we subject to Q and P defines, we're also included in the unnamed namespace now. Amends df030e06a81cf636aa766053af979ae79c2ab69d. Pick-to: 6.6 Change-Id: Ie2f4c9f45d9845d8a26140e0e1214e87b615ff02 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringBuilder: test more concatenation variantsAhmad Samir2023-07-241-0/+47
| | | | | | | | | | | | | | - rvalues, they work due to e.g. the implicit conversion to QString, so the compiler picks the "const String &" overloads. (This may change by adding rvalue overloads in a later commit, although that will mean adding many more operator+() overloads to disambiguate the calls) - QByteArray + QByteArrayView - More P and more Q (even though in some cases P and Q are defined as the same operator in some QStringBuilder unittest "scenarios") Change-Id: I4e7daecdb6887fb52f45732cd32323af20b1b850 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Make corelib tests standalone projectsAlexandru Croitor2023-07-051-0/+6
| | | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringBuilder: one less macro in unittestsAhmad Samir2023-06-261-13/+8
| | | | | | | Two QCOMPARE calls aren't worth the extra indirection. Change-Id: If3b54d303c28582c7df29a3f1c4dc1a2c2a974f4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringBuilder: allow to be used with 'auto' keywordVladimir Belyavsky2023-06-131-0/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is to store a concatenable in a QStringBuilder object by value or by reference, depending on how it was originally passed into the concatenation operator. So if it was passed by r-value, we treat it as a temporary object and hold it by value (and use move-semantic if available), otherwise we hold it by reference (as before). To achieve this we first change concatenation operators '%' and '+' to take their arguments by universal reference. Next we instantiate QStringBuilder object with deduced types of the arguments, which will be a "value type" or a "reference type" according to "universal reference deduction rules". Further we use perfect forwarding to pass arguments to QStringBuilder's constructor. Thus arguments, initially passed by r-value reference and which are move-constructible, will be "moved" to corresponding QStringBuilder member variables. So, to summarize: 1. Arguments passed by l-value reference - stored in QStringBuilder object by reference (as before). 2. Temporary objects passed by r-value reference - stored in QStringBuilder object by value. If a type is move-constructible (QSting, QByteArray, etc), the object will be "moved" accordingly. Special thanks to Giuseppe D'Angelo for the tests. Fixes: QTBUG-99291 Fixes: QTBUG-87603 Fixes: QTBUG-47066 Task-number: QTBUG-74873 Task-number: QTBUG-103090 Task-number: QTBUG-104354 Change-Id: I64f417be0de0815ec5ae7e35a1cc6cef6d887933 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Vladimir Belyavsky <belyavskyv@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QStringBuilder: remove QString/QByteArray specializationsVladimir Belyavsky2023-06-091-5/+3
| | | | | | | | | | This is an improved version of the previous attempt to remove this 3c6c3eccd1f91bd1ae0a518318ef264f8eff63f5. Now we also take into account that concatenation of 2 null stings must also produce null string as a result. Change-Id: I39c270552839b056247c1cce334cef4fa8f1cfdd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "QStringBuilder: remove unneeded specializations"Andy Nichols2023-06-061-0/+26
| | | | | | | | | | | | | This reverts commit 3c6c3eccd1f91bd1ae0a518318ef264f8eff63f5. Reason for revert: They do appear to be needed, and removing them changes behavior: QTBUG-114206 Pick-to: 6.6 Fixes: QTBUG-114206 Task-number: QTBUG-114238 Change-Id: Iac75bbc1ef14fe89f4282bd58fe996f9a09b8506 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-171-2/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Adapt the qstringbuilder test for batchingMikolaj Boc2023-01-101-5/+5
| | | | | | | | | | | There are numerous conflicting symbols in the tst_qstringbuilder\d variants when batching those together. Remove the linkage from symbols by putting the common include stringbuilder.cpp in an unnamed namespace. Task-number: QTBUG-109954 Change-Id: Ic2a745795b57482c90c9def7667a1145cdb19854 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-162-54/+4
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* tst_QStringBuilder: remove test that doesn't test anythingMarc Mutz2021-12-221-10/+0
| | | | | | | | | | | | We now have a more reliable test for the case with freeSpaceAtBegin(), so remove the old test, after we verified it actually doesn't even test that case. Task-number: QTBUG-99330 Pick-to: 6.3 6.2 Change-Id: Ic108a722cd2fef1e63a05085a76d7572d1f8c875 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tst_QStringBuilder: verify a comment is actually misleadingMarc Mutz2021-12-211-0/+2
| | | | | | | | | | | | | | | | The construction of the byte array doesn't actually yield freeSpaceAtBegin() (anymore?), so the comment above it is misleading (and the test didn't manage to catch QTBUG-99330, either). Before removing the misleading test, verify that this assumption is actually correct across all platforms. Task-number: QTBUG-99330 Pick-to: 6.3 6.2 Change-Id: I2f497321abc26c4148ced5ac12a5880b9ff5ba9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QStringBuilder: handle freeSpaceAtBegin() in op+=Marc Mutz2021-12-211-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends 9b320edb535a0fbe118933d2e983b73f90c32685. The above commit made the mistake of relying on the 30yr+ old fundamental relation size() - capacity() == freeSpaceAtEnd() which, however, Qt 6's prepend()-optimization (freeSpaceAtBegin()) broke. Because of that, while size() - capacity() may be large enough to hold the new data, if freeSpaceAtBegin() > 0, then freeSpaceAtEnd() may not. Fix by inspecting freeSpaceAtEnd() instead of capacity(). The following reserve() call is unaffected, since it internally already adds freeSpaceAtBegin() to the requested size, which is why the unconditional reserve() in 9b320edb535a0fbe118933d2e983b73f90c32685^ worked while 9b320edb535a0fbe118933d2e983b73f90c32685's capacity() check did not. Fixes: QTBUG-99330 Pick-to: 6.2 6.3 Change-Id: I520f36216011423f97a24484263acd40d8b1fa43 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QStringBuilder: Add support for QByteArrayViewMårten Nordheim2021-12-041-0/+4
| | | | | | | [ChangeLog][QtCore][QStringBuilder] Added support for QByteArrayView. Change-Id: If2c23549d533dd31c320f3ee455fcd01ea5b460a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-4/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-2/+2
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-09-231-1/+1
| | | | | | | | | | | Modify special case locations to use the new API as well. Clean up some stale .prev files that are not needed anymore. Clean up some project files that are not used anymore. Task-number: QTBUG-86815 Change-Id: I9947da921f98686023c6bb053dfcc101851276b5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Purge Q_{STDLIB,COMPILER}_UNICODE_STRINGSEdward Welbourne2020-09-141-8/+0
| | | | | | | | | These were now always defined, hence redundant. Leave the #define in place so that we can verify we actually do always define it, in a #else of an existing #if check on it. Change-Id: Iea4c3dbc8f9982268bcf81da5ef17fe2ebf5c462 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray: Disregard space at front during ::reserve(...)Mårten Nordheim2020-09-021-0/+8
| | | | | | | | | | | | Traditionally when calling reserve it's because you expect to append up to X amount of bytes. We should keep that behavior the same. With another patch still in the works current behavior caused an issue with QStringBuilder in QNAM, as mirrored in the testcase attached. Change-Id: I9792a8f158fc9235e3de48ac8b06ac2c10e7f3dc Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move QStringRef and remains to Qt5CompatKarsten Heimrich2020-08-201-18/+4
| | | | | | | | | Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CMake: Regenerate tests with new qt_ prefixed APIsAlexandru Croitor2020-07-091-1/+1
| | | | | | | | Use pro2cmake with '--api-version 2' to force regenerate projects to use the new prefixed qt_foo APIs. Change-Id: I055c4837860319e93aaa6b09d646dda4fc2a4069 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Remove QByteArray's methods taking QString and their usesSona Kurazyan2020-06-251-6/+0
| | | | | | | | | | [ChangeLog][QtCore][QByteArray] Remove method overloads taking QString as argument, all of which were equivalent to passing the toUtf8() of the string instead. Change-Id: I9251733a9b3711153b2faddbbc907672a7cba190 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Allow qMin, qMax and qBound for types that can be losslessly convertedLars Knoll2020-06-251-0/+1
| | | | | | | | | | | | | | | | Add overloads for qMin and friends where the arguments are of different type, but one can be easily promoted to the other. Return the promoted type. Promotions are only allowed if both types are either signed, unsigned or floating point numbers. This should simplify writing code in many case (as for example qMin(myint64, 1)) and also help reduce source incompatibilities between Qt 5 and Qt 6, where the return types for sizes of our containers changes from int to qsizetype. Change-Id: Ia6bcf16bef0469ea568063e7c32f532da610d1cd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringBuilder: code tidies in the testsGiuseppe D'Angelo2020-06-042-5/+9
| | | | | | | | | | | Including other headers, while defining very questionable macro names, can and will result in trouble. Stop doing that. While at it, move from including <QtTest> to include-what-you-use, and clean up the code a bit. Change-Id: Idb02ef2b612c0805baecac3ce6edd435609aca4c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Regenerate tests/auto/corelib/textAlexandru Croitor2019-11-121-1/+10
| | | | | | | | Change-Id: I34e24b7c2697bcdddc628855e2b539b8db1b98b0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Qt CMake Build Bot
* Merge branch 'wip/qt6' into wip/cmakeAlexandru Croitor2019-08-151-0/+1
| | | | Change-Id: I50ac36b8803c296998149e98cc61e38687cdd14b
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-103-0/+429
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>