summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms
Commit message (Collapse)AuthorAgeFilesLines
* Fix most GCC test failures.Eric Fiselier2018-01-183-7/+6
| | | | | | | | | | | | | | | | | | | | | | | This patch fixes almost all currently failing tests when using GCC ToT. The specific changes are: (A) Workaround gcc.gnu.org/PR83921 which rejects variables w/o initializers in constexpr contexts -- even when the variable is an empty class. This bug has been worked around at all callsites by adding an initializer. Additionally a new test, constexpr_init.pass.cpp, has been added to test that Clang doesn't suffer from these bugs. (B) Fix streambuf.assign/swap.pass.cpp. This test was never actually calling the swap method as intended. In fact, the swap function it intended to call was ill-formed when instantiated. GCC diagnosed this ill-formedness w/o needing an instantiation. (C) size_delete11.pass.cpp was fixed by adding c++2a to the list of unsupported dialects. llvm-svn: 322810
* More constexpr algorithms from P0202. search/search_nMarshall Clow2018-01-164-4/+79
| | | | llvm-svn: 322566
* More constexpr algorithms from P0202: lower_bound, upper_bound, equal_range, ↵Marshall Clow2018-01-1610-22/+155
| | | | | | binary_search llvm-svn: 322529
* Actually CALL the constexpr tests.Marshall Clow2018-01-162-0/+8
| | | | llvm-svn: 322528
* More constexpr (re P0202) - equal and mismatchMarshall Clow2018-01-164-4/+146
| | | | llvm-svn: 322527
* Fix constexpr failure on C++11-based buildbots.Marshall Clow2018-01-151-1/+1
| | | | llvm-svn: 322507
* More constexpr from P0202. count and count_if. Also fix a comment that ↵Marshall Clow2018-01-152-4/+33
| | | | | | Morwenn noted. llvm-svn: 322506
* Some of the tests from earlier today had 'int' as the return type when it ↵Marshall Clow2018-01-1515-15/+15
| | | | | | should have been 'bool'. Fix that. It doesn't change the behavior of any of the tests, but it's more accurate. llvm-svn: 322505
* More P0202 constexpr-ifying. All the find_XXX algorithms in this commit.Marshall Clow2018-01-159-14/+192
| | | | llvm-svn: 322504
* partition_point gets the P0202 treatmentMarshall Clow2018-01-153-4/+21
| | | | llvm-svn: 322493
* More constexpr algorithms from P0202. any_of/all_of/none_of.Marshall Clow2018-01-153-3/+48
| | | | llvm-svn: 322492
* First part of P0202: Adding constexpr modifiers to functions in <algorithm> ↵Marshall Clow2018-01-1511-8/+173
| | | | | | and <utility>. This commit is all the is_XXX algorithms. llvm-svn: 322489
* Fix misspelled macro name - thanks to andrew@ispras.ru for the catchMarshall Clow2018-01-101-1/+1
| | | | llvm-svn: 322196
* Add the C++17 extensions to std::search. Include the default searcher, but ↵Marshall Clow2018-01-081-0/+28
| | | | | | not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked to XFAIL. The other searchers will follow soon llvm-svn: 322019
* [libcxx] [test] Fix MSVC warnings, null pointer deref.Stephan T. Lavavej2017-12-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp Silence MSVC warning C4244. This is expected when passing floating-point values for size. test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp Avoid MSVC "warning C4293: '<<': shift count negative or too big, undefined behavior". MSVC sees (1ULL << N) and warns - being guarded by const bool canFit is insufficient. A small change to the code avoids the warning without the need for a pragma. Remove a spurious printf() declaration from to_ullong.pass.cpp. Change ULL to UL in to_ulong.pass.cpp. The ULL suffix was probably copy-pasted. test/std/utilities/tuple/tuple.general/ignore.pass.cpp Use LIBCPP_STATIC_ASSERT for consistency with other files. test/support/container_test_types.h Fix a null pointer dereference, found by MSVC /analyze warning C6011 "Dereferencing NULL pointer 'm_expected_args'." Fixes D41030. llvm-svn: 320535
* Fix PR#35948: generate_n does not accept floating point Size arguments.Marshall Clow2017-12-041-5/+18
| | | | llvm-svn: 319675
* Change (void) casts to TEST_IGNORE_NODISCARD, as requested by Eric. Reviewed ↵Billy Robert O'Neal III2017-11-211-1/+1
| | | | | | as https://reviews.llvm.org/D40065 llvm-svn: 318804
* Tolerate even more [[nodiscard]] in the STL. Reviewed as ↵Billy Robert O'Neal III2017-11-152-2/+2
| | | | | | https://reviews.llvm.org/D39080 llvm-svn: 318277
* Mark test as unsupported on C++98/03, since it uses move_iteratorMarshall Clow2017-10-301-0/+2
| | | | llvm-svn: 316917
* Fix PR#35119 : set_union misbehaves with move_iterators. Thanks to Denis ↵Marshall Clow2017-10-301-0/+44
| | | | | | Yaroshevskiy for both the bug report and the fix. llvm-svn: 316914
* Fix test for C++03Marshall Clow2017-08-291-3/+4
| | | | llvm-svn: 311967
* Fix PR31166: std::inplace_merge seems to be unstable. Thanks to Jan Wilken ↵Marshall Clow2017-08-281-0/+21
| | | | | | Dörrie for the suggested fix. llvm-svn: 311952
* [libcxx] [test] Change comments to say C++ instead of c++. NFC.Stephan T. Lavavej2017-07-292-2/+2
| | | | | | | | This makes them consistent (many comments already used uppercase). The special REQUIRES, UNSUPPORTED, and XFAIL comments are excluded from this change. llvm-svn: 309468
* [libcxx] [test] Untabify, NFC.Stephan T. Lavavej2017-07-297-47/+47
| | | | llvm-svn: 309464
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2017-06-201-5/+5
| | | | llvm-svn: 305848
* Add non-parallel version of for_each_n (+tests) from the Parallelism TSMarshall Clow2017-05-251-0/+61
| | | | llvm-svn: 303833
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2017-05-044-4/+4
| | | | llvm-svn: 302105
* Cleanup _LIBCPP_HAS_NO_<c++11-feature> in algorithmEric Fiselier2017-04-1815-101/+63
| | | | llvm-svn: 300625
* Update the algorithm tests to not use the (deprecated) function binders. No ↵Marshall Clow2017-03-237-14/+42
| | | | | | functional change. llvm-svn: 298618
* Use 'REQUIRES: c++98 || c++03 || c++11 || c++14' instead of the deprecated ↵Marshall Clow2017-03-232-2/+2
| | | | | | 'REQUIRES-ANY: c++98, c++03, c++11, c++14' llvm-svn: 298600
* Remove random_shuffle in C++17. Please use shuffle instead. If you have to, ↵Marshall Clow2017-03-232-0/+2
| | | | | | you cant get it back by defining _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE before including any libc++ headers. llvm-svn: 298597
* Stop using random_shuffle in the libc++ test suite. It's going to be removed ↵Marshall Clow2017-02-0727-35/+116
| | | | | | in c++17. Use shuffle() instead. No change to libc++, just the tests. llvm-svn: 294328
* Enable the -Wsign-compare warning to better support MSVCEric Fiselier2016-12-1117-97/+102
| | | | llvm-svn: 289363
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-083-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | loss of data", part 6/7. test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp (Affects 64-bit architectures.) Include <cstddef> so we can take/return std::ptrdiff_t (instead of int) in random_shuffle()'s RNG. (C++14 D.12 [depr.alg.random.shuffle]/2 says that difference_type is used, and we're shuffling a plain array.) test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp (Affects 64-bit architectures.) Include <iterator> because we're already using iterator_traits. Then, store the result of subtracting two RanIts as difference_type instead of long (which truncates on LLP64 architectures like MSVC x64). test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp (Affects 64-bit architectures.) Include <cstddef> so we can store the result of subtracting two pointers as std::ptrdiff_t (instead of int). test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp (Affects 32-bit architectures.) Sometimes, size_t is too small. That's the case here, where tellg() returns pos_type (N4606 27.7.2.3 [istream.unformatted]/39). Implementations can have 64-bit pos_type (to handle large files) even when they have 32-bit size_t. Fixes D27543. llvm-svn: 289110
* [libcxx] [test] D27025: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-062-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | part 12/12. Various changes: test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp This is comparing value_type to unsigned. value_type is sometimes int and sometimes struct S (implicitly constructible from int). static_cast<value_type>(unsigned) silences the warning and doesn't do anything bad (as the values in question are small). test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp This is comparing an int remote-element to size_t. The values in question are small and non-negative, so either type is fine. I think that converting int to size_t is marginally better here than the reverse. test/std/containers/sequences/deque/deque.cons/size.pass.cpp DefaultOnly::count is int (and non-negative). When comparing to unsigned, use static_cast<unsigned>. test/std/strings/basic.string/string.access/index.pass.cpp We're comparing char to '0' through '9', but formed with the type size_t. Add static_cast<char>. test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp Include <cstddef> for pedantic correctness (this test was already mentioning std::size_t). "v[i] == (i & 1)" was comparing bool to size_t. Saying "v[i] == ((i & 1) != 0)" smashes the RHS to bool. llvm-svn: 288749
* [libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-065-7/+7
| | | | | | | | | | | | part 10/12. Add static_cast<int>. In these cases, the values are guaranteed to be small-ish, and they're being compared to int elements. test/std/containers/sequences/deque/deque.capacity/access.pass.cpp Use int instead of unsigned to iterate from 0 to 10. llvm-svn: 288747
* [libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-061-3/+4
| | | | | | | | | | part 9/12. Add static_cast<std::size_t> to more comparisons. (Performed manually, unlike part 8/12.) Also, include <cstddef> when it wasn't already being included. llvm-svn: 288746
* Work around more -Wshadow warningsEric Fiselier2016-12-031-1/+1
| | | | llvm-svn: 288573
* [libcxx] [test] D27027: Strip trailing whitespace.Stephan T. Lavavej2016-11-232-4/+4
| | | | llvm-svn: 287829
* [libcxx] [test] D27018: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-231-1/+1
| | | | | | | | | | | | | | | | | | | part 5/12. Various changes: test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp Change M from unsigned to int. It's compared against "int x", and we binary_search() for it within a vector<int>. test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp Add static_cast<unsigned> when comparing int to unsigned. test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp Change unsigned indices to int when we're being given int as a bound. llvm-svn: 287825
* [libcxx] [test] D27015: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-2321-29/+29
| | | | | | | | part 3/12. Change unsigned to int in parameters. llvm-svn: 287823
* [libcxx] [test] D27014: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-234-6/+10
| | | | | | | | | | part 2/12. Add static_cast<std::size_t> when comparing int to std::size_t. Also, include <cstddef> when it wasn't already being included. llvm-svn: 287822
* [libcxx] [test] D27013: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-238-8/+16
| | | | | | | | | | part 1/12. Change loop indices from int to std::size_t. Also, include <cstddef> when it wasn't already being included. llvm-svn: 287820
* [libcxx] [test] D26816: Fix non-Standard assumptions when testing sample().Stephan T. Lavavej2016-11-181-3/+14
| | | | | | | | | | | | | sample() isn't specified with a reproducible algorithm, so expecting exact output is non-Standard. Mark those tests with LIBCPP_ASSERT. In test_small_population(), we're guaranteed to get all of the elements, but not necessarily in their original order. When PopulationCategory is forward, we're guaranteed stability (and can therefore test equal()). Otherwise, we can only test is_permutation(). (As it happens, both libcxx and MSVC's STL provide stability in this scenario for input-only iterators.) llvm-svn: 287383
* Add missing include in test; NFC. Thanks to Jonathan Wakely for the report.Marshall Clow2016-10-131-0/+1
| | | | llvm-svn: 284120
* Purge all usages of _LIBCPP_STD_VER under test/std/algorithmEric Fiselier2016-10-0817-121/+132
| | | | llvm-svn: 283643
* Implement C++17 std::sample.Eric Fiselier2016-08-283-0/+244
| | | | | | | | This patch implements the std::sample function added to C++17 from LFTS. It also removes the std::experimental::sample implementation which now forwards to std::sample. llvm-svn: 279948
* Mark LWG 2716 as complete - shuffle and sample disallows lvalue URNGs.Eric Fiselier2016-08-281-1/+1
| | | | | | | | | | | Libc++'s implementation of shuffle and sample already support lvalue and rvalue RNG's. This patch adds tests for both categories and marks the issue as complete. This patch also contains drive-by change for std::experimental::sample which improves the diagnostics produced when the correct iterator categories are not supplied. llvm-svn: 279947
* Fix portability issues in <random> tests. Patch from STL@microsoft.comEric Fiselier2016-07-243-5/+16
| | | | llvm-svn: 276585
* Implement LWG#2688: 'clamp misses preconditions and has extraneous condition ↵Marshall Clow2016-06-302-4/+135
| | | | | | on result'. We already did this, just added tests llvm-svn: 274252
OpenPOWER on IntegriCloud