summaryrefslogtreecommitdiff
path: root/tests/auto/algorithm/tst_algorithm.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove GPL-3.0+ from license identifiersKai Köhne2023-01-061-1/+1
| | | | | | | | | | | | | | | Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0, this applies only to a hypothetical newer version of GPL, that doesn't exist yet. If such a version emerges, we can still decide to relicense... While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only Change was done by running find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \; Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Fix that Utils::sorted could modify input containerEike Ziller2023-01-031-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | Utils::sorted had overloads for "const Container &", "Container &&", and "const Container &&", but for _templated_ types "Container &&" does _not_ mean "rvalue reference", it means "rvalue or lvalue reference" (e.g. "universal" reference). That means that for non-const lvalue references that "Container &&" overload was used, which modifies the input container. Which is a fine optimization for rvalue references, but is wrong for lvalue references. Add another overload explicitly for "Container &" before the "Container &&" overload, and add some tests. Also fix the compiler warning that triggered the investigation: warning: local variable 'container' will be copied despite being returned by name [-Wreturn-std-move] note: call 'std::move' explicitly to avoid copying Amends 13f40f5471e55757a2cf9bba8d052750a2f2a753 Change-Id: I14461fde5fc51a8bb679fd72b886e13b18c47e7b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
* Utils: Add sorted() functionChristian Kandeler2022-10-251-6/+3
| | | | | | | | | For simpler calling code. Change-Id: Ia0a16a28770fd172f74d06a626148248bf5d3c0c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Utils: Remove Utils::optionalEike Ziller2022-09-011-5/+5
| | | | | | | | | | Since we are now requiring macOS 10.14 we can remove our local implementation of optional and use std::optional for macOS too. Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Use SPDX license identifiersLucie Gérard2022-08-261-24/+2
| | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Task-number: QTBUG-67283 Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Collapse most of porting,hhjk2022-07-131-14/+12
| | | | | | | | | Taking the Qt 6 branches, leaving some dummies until downstream adapted. Change-Id: Ib9b86568d73c341c8f740ba497c3cbfab830d8a1 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use QTEST_GUILESS_MAIN where applicableEike Ziller2022-06-131-1/+1
| | | | | | | | | | instead of QTEST_MAIN. Reduces the initialization that is done by the Qt test applications, and can also reduce interference with normal OS operations like the current window loosing focus. Change-Id: If88f289281aa1c8703ac7d4dbe0799d067c16588 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix building tests with Qt6Eike Ziller2020-10-301-12/+14
| | | | | | Task-number: QTCREATORBUG-24098 Change-Id: I192245125f04f8350597bbe481d80d3f8ba0cae0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Tests: Fix compile for older compiler / QtChristian Stenger2018-03-131-9/+9
| | | | | Change-Id: I96e48c446ebd397c75dc0b47f9aaef1717b5e5af Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Utils: Add pointeralgorithm.hTobias Hunger2018-03-121-79/+16
| | | | | Change-Id: I3e81bdbf22808efbe1fb5fab13bef24c8f73f404 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Add takeTobias Hunger2018-03-121-0/+26
| | | | | | | | | | | Add a new algorithmn to take the first match in a container out of the container. It takes a pointer to something and will try to match against a smart pointer stored in the container. Besides that it also accepts the usual like a predicate, member variable or member function. Change-Id: I4aabd4d43aa076a534da6488d0f9c3695ba79c09 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils::transform: Add support for various map types as resultEike Ziller2017-12-201-0/+65
| | | | | | | | | | Add support for output as std::map/unordered_map/set and QMap and QHash, when giving the full result type as template argument. For std:: (unordered_)map, the function must return a std::pair<Key,Value>, for QMap and QHash it can also be QPair<Key,Value>. Change-Id: If3dff17ab6aa5d1b11abc244813fd885d10c75a4 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Utils::transform: Support containers without reserve()Eike Ziller2017-12-201-2/+34
| | | | | | | | Support containers without reserve() as result container, for example std::set/deque/list Change-Id: Ia96b834c67d5ee74bfb9de2cf6b86639f6b3d5d7 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Utils: Converter to raw pointer and referencesMarco Bubke2017-12-201-0/+53
| | | | | | | | Sometimes you want to get raw pointer container from smart pointer container and reference container from value container. Change-Id: Ia018d572ac0a7bf742f3937dc38ee30670a3ca73 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils::transform: Allow usage with non-const source containersEike Ziller2017-12-191-0/+31
| | | | | | | Makes it possible to e.g. transform to list of reference_wrappers. Change-Id: Ib608034fc3f296824c289edd27563bc7a196ac6d Reviewed-by: hjk <hjk@qt.io>
* Tests: Fix compile with MSVC2015Christian Stenger2017-12-131-2/+2
| | | | | Change-Id: Ic9a1839325febeb6bde0b656dce88342f3955c53 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Support specifying complete result type in Utils::transformEike Ziller2017-12-121-4/+62
| | | | | | | | | | | | | | Can come in handy when the function or member does not directly return the right value type for the result list, but is implicitly convertable to it. For example from pointer to class to pointer to superclass, or from int to double. const auto result = Utils::transform<QVector<double>>(v, &ValueType::intMember) Change-Id: I0e1914d70bb2580b91098dd37e85a31ca14b0ae6 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Simplify transform and add support for more input container typesEike Ziller2017-12-071-0/+13
| | | | | Change-Id: Ib75cfcc7741be686c0117fbb27df869e14db4f69 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Utils: Clean up Utils::findOr and Utils::findOrDefaultTobias Hunger2017-12-011-1/+18
| | | | | Change-Id: I638e68480d3985b6df9a18aa96a067ee68484b12 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Support more containers with Utils::transformTobias Hunger2017-12-011-0/+73
| | | | | | | Support std::vector and similar classes as input and output. Change-Id: I1d202d54c18e868ce0e71e4c2b6288565710baa8 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Improve Utils::containsTobias Hunger2017-12-011-0/+12
| | | | | | | | * Consistently use anyOf to implement contains. * Support contains over an container of std::unique_ptr matching a pointer. Change-Id: I0180f3ec3d5935d8afeeac67a745d4b38a01674d Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Implement more Utils::anyOf variationsTobias Hunger2017-12-011-0/+24
| | | | | Change-Id: I0cba5b58dde6003f5c5cb399142f985cbe83f0a7 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Tests: Fix compile on Windows and LinuxChristian Stenger2017-11-301-4/+6
| | | | | | | | | | | | Template code inside utils/algorithm.h is not correctly instantiated when respective containers that shall use these functions are included after the algorithm file. Additionally there had been issues using nullptr as comparison inside QCOMPARE(). Change-Id: I2bd6baf3890090c5f5bbbd6229afb9aeeb7617ef Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Add missing include to algorithm testEike Ziller2017-11-291-3/+4
| | | | | Change-Id: Ia7302723a0ec41456ca99704b7f8c680f6893c5d Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Algorithm: Support std::vector<std::unique_ptr> with contains and findOrEike Ziller2017-11-291-0/+63
| | | | | Change-Id: I01cb71c06b405f071498ed8752f9acac44d2b223 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* Tests: Fix compile on Linux and WindowsChristian Stenger2017-11-281-2/+3
| | | | | Change-Id: Ie8db68769a2419c9ad8700d9eef1d4093c209d9b Reviewed-by: hjk <hjk@qt.io>
* Utils: Make algorithms take more containersTobias Hunger2017-11-271-0/+14
| | | | | | Change-Id: I05bd1052bbc2c6481fdec8a3763d9ae4f3dc8f44 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Algorithm: Add a member variant for transformOrgad Shaneh2017-03-101-10/+15
| | | | | Change-Id: I329ee764cc13dd8b794c6769a2baf2f41d6a9983 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Tests: Do not use deprecated Qt algorithmsOrgad Shaneh2016-08-151-3/+3
| | | | | Change-Id: I3ca177b69df3540729a98d8d3b6287df36a47ea0 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Algorithm: Allow sorting container of pointers with member (function)Eike Ziller2016-08-091-0/+10
| | | | | Change-Id: I2928081750f86b66e969ec2f7ade9e67ce19a825 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Utils: Introduce sort variants for member and member functionOrgad Shaneh2016-08-091-0/+27
| | | | | Change-Id: Iff29f2c55a08e85de7f0ff4e431f326e351e5305 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Tests: Fix compile with Qt5.5/MSVC 2013Christian Stenger2016-07-221-2/+2
| | | | | | Change-Id: I60b7222380486c965701abf6fcbfad460797ab27 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Add auto test for algorithmsEike Ziller2016-07-111-0/+116
The currently most interesting is Utils::transform. Change-Id: Ic21ec098f15ae4564227a84d11ef95f57ac72d6c Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>