summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qbytearray
Commit message (Collapse)AuthorAgeFilesLines
* Prefer QCOMPARE to QVERIFY, as it gives better outputJoão Abecasis2012-04-121-1/+1
| | | | | | Done-by: Jędrzej Nowacki Change-Id: Ic1c8fd5b8acede52b45e5ea16b14fb5bae78f171 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate qMemCopy/qMemSet in favour of their stdlib equivilents.Robin Burchell2012-04-111-4/+4
| | | | | | | | | | | | | | | | | | Just like qMalloc/qRealloc/qFree, there is absolutely no reason to wrap these functions just to avoid an include, except to pay for it with worse runtime performance. On OS X, on byte sizes from 50 up to 1000, calling memset directly is 28-15% faster(!) than adding an additional call to qMemSet. The advantage on sizes above that is unmeasurable. For qMemCopy, the benefits are a little more modest: 16-7%. Change-Id: I98aa92bb765aea0448e3f20af42a039b369af0b3 Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com> Reviewed-by: John Brooks <john.brooks@dereferenced.net> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Add test for qHash(QByteArray)Giuseppe D'Angelo2012-04-061-0/+4
| | | | | | | Two equal QByteArrays must return the same hash. Change-Id: Iddd45b0c420213ca2b82bbcb164367acb6104ec8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add zero-termination checks to QString and QByteArray testsJoão Abecasis2012-04-051-0/+59
| | | | | | | | | | | | | | This uses an alternative approach to the testing formerly introduced in 4ef5a626. Zero-termination tests are injected into all QCOMPARE/QTEST invocations. This makes such testing more thorough and widespread, and gets seamlessly extended by future tests. It also fixes an issue uncovered by the test where using a past-the-end position with QString::insert(pos, char), could move uninitialized data and clobber the null-terminator. Change-Id: I7392580245b419ee65c3ae6f261b6e851d66dd4f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Revert "Add tests to verify QByteArray's zero termination"João Abecasis2012-04-051-123/+5
| | | | | | | | | | | | | The approach used to verify for zero-termination is too intrusive and requires additional maintenance work to ensure new zero-termination tests are added with new functionality. Zero-termination testing will be re-established in a subsequent commit. This reverts commit 4ef5a6269c1465662ea3872596ba284a13cce25e. Change-Id: I862434a072f447f7f0c4bbf8f757ba216212db3c Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Clean up constructors for "statics" in QString and QByteArrayJoão Abecasis2012-04-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were two constuctors offering essentially the same functionality. One taking the QStatic*Data<N> struct, the other what essentially amounts to a pointer wrapper of that struct. The former was dropped and the latter untemplatized and kept, as that is the most generic and widely applicable. The template parameter in the wrapper was not very useful as it essentially duplicated information that already maintained in the struct, and there were no consistency checks to ensure they were in sync. In this case, using a wrapper is preferred over the use of naked pointers both as a way to make explicit the transfer of ownership as well as to avoid unintended conversions. By using the reference count (even if only by calling deref() in the destructor), QByteArray and QString must own their Data pointers. Const qualification was dropped from the member variable in these wrappers as it causes some compilers to emit warnings on the lack of constructors, and because it isn't needed there. To otherwise reduce noise, QStatic*Data<N> gained a member function to directly access the const_cast'ed naked pointer. This plays nicely with the above constructor. Its use also allows us to do further changes in the QStatic*Data structs with fewer changes in remaining code. The function has an assert on isStatic(), to ensure it is not inadvertently used with data that requires ref-count operations. With this change, the need for the private constructor taking a naked Q*Data pointer is obviated and that was dropped too. In updating QStringBuilder's QConcatenable specializations I noticed they were broken (using data, instead of data()), so a test was added to avoid this happening again in the future. An unnecessary ref-count increment in QByteArray::clear was also dropped. Change-Id: I9b92fbaae726ab9807837e83d0d19812bf7db5ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add tests to verify QByteArray's zero terminationJoão Abecasis2012-03-301-5/+123
| | | | | | | | | | | | | | | | For data allocated and maintained by QByteArray, there's a guarantee that data() is null-terminated. This holds true even for null and empty, where logically the terminating character should never be dereferenced. For tests that modify or generate QByteArrays, this ensures the invariant is kept. In the toFromHex() text, const-ness of temporary variables was dropped to enable the test macro to be used, as the qualification didn't add much to the test otherwise. Change-Id: I7ee52e79e3a9df7de18c743f3698dab688e6bf0e Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Move the QByteArray-based percent-encoding activities to QByteArrayThiago Macieira2012-03-301-0/+91
| | | | | | | | | | Copy the unit tests that related to percent-encoding to tst_qbytearray.cpp and use public functions to execute QUrl::fromPercentEncoded and QUrl::toPercentEncoded. Change-Id: I6639ea566d82dabeb91280177a854e89e18f6f8d Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: David Faure <faure@kde.org>
* Add test cases to tst_QByteArrayJędrzej Nowacki2012-03-231-0/+137
| | | | | | | | | | Internally we construct QByteArrays from QStaticByteArrays. For example moc is generating QStaticByteArray structure for every string it saves. New test cases check if a QByteArray constructed from a QStaticByteArray behaves as a not statically constructed one. Change-Id: Ia4aa9a1a5bc0209507636c683a782dda00eae85c Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Merge remote-tracking branch 'gerrit/master' into containersJoão Abecasis2012-02-211-18/+21
|\ | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.h Change-Id: I03b1f3e05c9b7a45130887c522fcd9b7aa387129
| * Eliminate duplicate data row names from corelib autotests.Jason McDonald2012-02-141-18/+18
| | | | | | | | | | Change-Id: I57a37f19746b76c6c9c3534f5c66c5a5478dae24 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
| * Make "nmake check" pass for corelib tests in Windows.Miikka Heikkinen2012-02-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Marked four tests insignificant due to failures, these need to be fixed later and then re-enabled: - tst_qfilesystemwatcher - tst_qsettings - tst_qlibrary - tst_qsharedpointer - Skipped one invalid case (tst_QCoreApplication::argc()) - Ifdeffed around vsprintf issue in MSVC (tst_QByteArray::qvsnprintf()) Task-number: QTBUG-24157 Task-number: QTBUG-24146 Task-number: QTBUG-24128 Change-Id: I4db957a65fbf0093f5ae3dc1a04d792492818104 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
* | Change meaning of offset in QByteArrayDataJoão Abecasis2012-02-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It used to be an index into the first element in 'd' that came after 'offset'. It is now the byte offset from the beginning of the QByteArrayData structure. By no longer using an actual array to access characters, we also steer clear of GCC bug #43247: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247 This aligns this data structure with QArrayData. The intention is to have QVector, QString and QByteArray share the same memory layout and possibly code. Change-Id: I8546e5f51cd2161ba09bd4ada174b7f5e6f09db7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | qAllocMore: Always grow exponentiallyJoão Abecasis2012-02-171-12/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qAllocMore is used by growing containers to allocate additional memory for future growth. The previous algorithm would grow linearly in increments of 8 up to 64 and then progress exponentially in powers of two. The new (constant time) algorithm does away with the linear segment and always progresses exponentially. It also has the nice benefit of cleanly avoiding undefined behaviour that the old implementation tried hard to circumvent. Besides always progressing exponentially, the next-power-of-two algorithm was tweaked to always include space for growth. Previously queries at boundary values (powers of two) would return the same value. The test was updated to verify sanity of results. As the algorithm is well behaved, testing of bogus data was dropped. Whatever happens in those cases is irrelevant, anyway: the bug lives elsewhere. Change-Id: I4def473cce4b438734887084e3c3bd8da0ff466b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* | Merge remote-tracking branch 'gerrit/master' into containersJoão Abecasis2012-02-051-3/+83
|\| | | | | | | | | | | | | Conflicts: src/corelib/tools/qstring.cpp Change-Id: I23d214bf33c2badfae1876da3cc7d6d8f6e635fb
| * Add movability tests for QByteArray.Jędrzej Nowacki2012-02-051-1/+81
| | | | | | | | | | | | | | QByteArray is declared as movable but it was not tested before. Change-Id: I4fb636f8705c3fd792a768872206203ee5fd4ddb Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
| * Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
| * Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | | | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* | Don't use RefCount int operatorsJoão Abecasis2012-01-231-1/+1
|/ | | | | | | | | | | | | , as those are going away. The comment in QString/QByteArray::squeeze about shared_null was updated as it also affects other static data, such as that generated by QStringLiteral and QByteArrayLiteral. Change-Id: I26a757d29db62b1e3566a1f7c8d4030918ed8a89 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove TESTED_CLASS/TESTED_FILES comments from tests.Jason McDonald2011-12-061-3/+0
| | | | | | | | | These comments were mostly empty or inaccurate. Appropriate naming of tests and appropriate placement of tests within the directory tree provide more reliable indicators of what is being tested. Change-Id: Ib6bf373d9e79917e4ab1417ee5c1264a2c2d7027 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Fixed installation of corelib testsRohan McGovern2011-12-012-9/+2
| | | | | | | | | | | | | | | | | In .pro files, removed wince/symbian-specific DEPLOYMENT cases and replaced them with TESTDATA where appropriate. In .cpp files, removed SRCDIR and relative paths to testdata and replaced them with the QFINDTESTDATA macro where appropriate. Modified test helper apps/libs to install themselves under the test they relate to. This change allows corelib tests to be correctly installed, along with their testdata, via `make install'. Change-Id: I5e202e2f3b577af7e39072d5c9fe13e0ca125304 Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
* Minor improvement to QByteArray autotestJason McDonald2011-12-011-28/+23
| | | | | | | | | | | | | | | | Rename the qUncompress test to make clear that the test only deals with uncompressing corrupted data and add a message making it clear that this test will produce some warning messages. Don't skip creating the test data, as that prevents the test output reporting exactly what is skipped. The expected output is the same for every row (an empty QByteArray), so don't bother storing that in the data table. Change-Id: I59f1cc91a941bcaadacb2a613dd5eca2564961c1 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-301-2/+0
| | | | | | | | Remove references to the old bug tracker. The data from the old bug tracker is no longer accessible, so these markers are meaningless. Change-Id: Ib9d029d52b70fd0a512b9532d65f03763eabfe57 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Restore commented-out code in QByteArray test.Jason McDonald2011-11-211-3/+3
| | | | | | | | | The restored code was inexplicably commented-out by commit d57aec33 (non-public history), which was only supposed to be changing upper-case booleans to lower-case. Change-Id: I1581fc89511f600c614871e1aec6bc030cddf40e Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Don't depend on moc to disable test functions.Jason McDonald2011-11-181-5/+4
| | | | | | | | | | | | | | | | | | | | | The moc tool is not aware of all defines (particularly those that are compiler builtins) and does not correctly evaluate others that depend on compiler builtins, such as Q_OS_FOO. This commit reverts parts of the following commits, but is not a complete fix as there were many instances of this problem in the tests prior to those commits: 924d810dbdcd5b5b0fa860922b2487ea9062d002 8aaff6751038b88d17e23be6fcee945771297c5b 338d3f11973412047c2c9cd41cbd0c961d738ef3 a55034062ba2bf73a9f1ed3d9cf31745b38149e3 253497b7446c7d723aa3bdd7152e25d6852f2604 7cfad460c56319ba89c4a3a0bbcb2e54ab1cdbc6 9d2ff58f3642828e494e7e9b2df7dbb8e2cd408f 0cf6baa2d61ebaad2a2a0530c37f27e719b68f4b Change-Id: I947d797fe3ec76139ba1b55561cea569895662c5 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-141-1/+0
| | | | | | | | | | | | | Remove various disabled and/or non-helpful debugging code. Any test diagnostics that are useful should be part of the regular test output, as the CI system cannot switch on commented-out code when there is a test failure. Diagnostics should also be informative -- simply printing the value of a variable with no other information about what is being printed (or why it is being printed) is not informative. Change-Id: I21a6c2121be86001bb57e80f426507b6e619ee9e Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* QByteArray autotest: Check for defines inside of slotOliver Wolff2011-11-111-4/+8
| | | | | | | | | | | Instead of creating slots depending on certain defines, these defines should be checked inside the slots. Moc may not be aware of all defines (e.g. compiler specific ones) and thus (not) create slots according to the condition given. Change-Id: I50495444b8f468ec131e6a0937e18803a8077758 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-111-15/+8
| | | | | | | | | | | | | Tidy the autotest .pro files. Most autotest .pro files should look like this: CONFIG += testcase TARGET = tst_something QT = core testlib SOURCES = tst_something.cpp Change-Id: I877c2194e9fa9dd13478d117895e1e255a948ad7 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-101-14/+13
| | | | | | | Remove literal tabs. Change-Id: I210a0259773cceb20d35ebc80b889e3ebb88b540 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-071-28/+0
| | | | | | | Remove redundant empty constructors, destructors and test functions. Change-Id: Idb51368895e67ec3fc0345a9a5d33d77730c051b Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* corelib: eliminated usage of qttest_p4.prfRohan McGovern2011-10-251-2/+3
| | | | | | | | | qttest_p4.prf was added as a convenience for Qt's own autotests in Qt4. It enables various crufty undocumented magic, of dubious value. Stop using it, and explicitly enable the things from it which we want. Change-Id: I7c1ffe9c8c294dbdc988e1582e580b1ed3f4593e Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
* Avoid using QSKIP in lieu of compile-time checksJason McDonald2011-10-051-18/+11
| | | | | | | | | | | | | | | | QSKIP is intended to be used to skip test functions that are found at run-time to be inapplicable or unsafe. If a test function can be determined to be inapplicable at compile-time, the entire test function should be omitted instead of replacing the body of the test function with a QSKIP, which only serves to slow down test runs and to inflate test run-rates with empty, inapplicable tests. Task-number: QTQAINFRA-278 Change-Id: Ib2025339422749cf216e87ac414a3056250bf8f9 Reviewed-on: http://codereview.qt-project.org/5942 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove Symbian-specific code from tests.Jason McDonald2011-09-292-7/+1
| | | | | | | | | Symbian is not a supported platform for Qt5, so this code is no longer required. Change-Id: I1172e6a42d518490e63e9599bf10579df08259aa Reviewed-on: http://codereview.qt-project.org/5657 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Fix QString and QByteArray reserve() and squeeze()Bradley T. Hughes2011-09-231-0/+6
| | | | | | | | | | | | | | | | | These functions should not take care not to unconditionally set the capacityReserved private member, since the d may be referencing the const shared_null or shared_empty which live in read-only memory. The squeeze() methods check for ref > 1 instead of ref != 1 to prevent detaching from the shared_null/shared_empty unnecessarily; the shared_null/shared_empty ref count is -1, meaning squeeze() will never detach from it. Change-Id: Id3f1725a6f08b3a462343640a47bbe78f08ca7e7 Rubberstamped-by: Lars Knoll Reviewed-on: http://codereview.qt-project.org/5454 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Moving relevant tests to corelib/toolsHolger Ihrig2011-09-015-0/+2491
Task-number: QTBUG-21066 Change-Id: I650f8f7826b9feea7c1484f06e03e10c68ec2b65 Reviewed-on: http://codereview.qt.nokia.com/3712 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>