summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers
Commit message (Collapse)AuthorAgeFilesLines
* [libcxx][test] Fix span tests.Stephan T. Lavavej2020-01-086-38/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | span.cons/container.pass.cpp N4842 22.7.3.2 [span.cons]/13 constrains span's range constructor for ranges::contiguous_range (among other criteria). 24.4.5 [range.refinements]/2 says that contiguous_range requires data(), and (via contiguous_range, random_access_range, bidirectional_range, forward_range, input_range, range) it also requires begin() and end() (see 24.4.2 [range.range]/1). Therefore, IsAContainer needs to provide begin() and end(). (Detected by MSVC's concept-constrained implementation.) span.cons/stdarray.pass.cpp This test uses std::array, so it must include <array>. <span> isn't guaranteed to drag in <array>. (Detected by MSVC's implementation which uses a forward declaration to avoid dragging in <array>, for increased compiler throughput.) span.objectrep/as_bytes.pass.cpp span.objectrep/as_writable_bytes.pass.cpp Testing `sp.extent == std::dynamic_extent` triggers MSVC warning C4127 "conditional expression is constant". Using `if constexpr` is a simple way to avoid this without disrupting anyone else (as span requires C++20 mode). span.tuple/get.pass.cpp 22.7.3.2 [span.cons]/4.3: "Preconditions: If extent is not equal to dynamic_extent, then count is equal to extent." These lines were triggering undefined behavior (detected by assertions in MSVC's implementation). I changed the count arguments in the first two chunks, followed by changing the span extents, in order to preserve the test's coverage and follow the existing pattern. span.cons/span.pass.cpp 22.7.3.2 [span.cons]/18.1 constrains span's converting constructor with "Extent == dynamic_extent || Extent == OtherExtent is true". This means that converting from dynamic extent to static extent is not allowed. (Other constructors tested elsewhere, like span(It first, size_type count), can be used to write such code.) As this is the test for the converting constructor, I have: * Removed the "dynamic -> static" case from checkCV(), which is comprehensive. * Changed the initialization of std::span<T, 0> s1{}; in testConstexprSpan() and testRuntimeSpan(), because s1 is used below. * Removed ASSERT_NOEXCEPT(std::span<T, 0>{s0}); from those functions, as they are otherwise comprehensive. * Deleted testConversionSpan() entirely. Note that this could never compile (it had a bool return type, but forgot to say `return`). And it couldn't have provided useful coverage, as the /18.2 constraint "OtherElementType(*)[] is convertible to ElementType(*)[]" permits only cv-qualifications, which are already tested by checkCV().
* [libcxx] [test] Include missing headers. (NFC)Stephan T. Lavavej2019-12-131-0/+4
| | | | | | | | libcxx/test/std/containers/sequences/array/at.pass.cpp Need to include <stdexcept> for std::out_of_range. libcxx/test/std/localization/locale.categories/category.time/* Need to include <ios> for std::ios.
* [libcxx] [test] Fix valarray UB and MSVC warnings.Stephan T. Lavavej2019-12-125-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [libcxx] [test] Calling min and max on an empty valarray is UB. libcxx/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp libcxx/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp The calls `v1.min();` and `v1.max();` were emitting nodiscard warnings with MSVC's STL. Upon closer inspection, these calls were triggering undefined behavior. N4842 [valarray.members] says: "T min() const; 8 Preconditions: size() > 0 is true. T max() const; 10 Preconditions: size() > 0 is true." As these tests already provide coverage for non-empty valarrays (immediately above), I've simply deleted the code for empty valarrays. [libcxx] [test] Add macros to msvc_stdlib_force_include.h (NFC). libcxx/test/support/msvc_stdlib_force_include.h These macros are being used by: libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp Defining them to nothing allows that test to pass. [libcxx] [test] Silence MSVC warning C5063 for is_constant_evaluated (NFC). libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.pass.cpp This test is intentionally writing code that MSVC intentionally warns about, so the warning should be silenced. Additionally, comment an endif for clarity. [libcxx] [test] Silence MSVC warning C4127 (NFC). libcxx/test/support/charconv_test_helpers.h MSVC avoids emitting this warning when it sees a single constexpr value being tested, but this condition is a mix of compile-time and run-time. Using push-disable-pop is the least intrusive way to silence this. [libcxx] [test] Silence MSVC truncation warning (NFC). libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp This test is intentionally truncating float to int, which MSVC intentionally warns about, so push-disable-pop is necessary. [libcxx] [test] Avoid truncation warnings in erase_if tests (NFC). libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp libcxx/test/std/containers/associative/multimap/multimap.erasure/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.map/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.multimap/erase_if.pass.cpp These tests use maps with `short` keys and values, emitting MSVC truncation warnings from `int`. Adding `static_cast` to `key_type` and `mapped_type` avoids these warnings. As these tests require C++20 mode (or newer), for brevity I've changed the multimap tests to use emplace to initialize the test data. This has no effect on the erase_if testing.
* [libc++][P1872] span should have size_type, not index_type.Louis Dionne2019-11-1411-16/+16
| | | | | | Thanks to Marek Kurdej for the patch. Differential Revision: https://reviews.llvm.org/D70206
* [NFC] Strip trailing whitespace from libc++Louis Dionne2019-10-2317-29/+29
|
* [libc++][NFC] Remove excess trailing newlines from most filesCasey Carter2019-10-236-6/+0
| | | | Testing git commit access.
* [libcxx][test][NFC] Fix comment typos.Stephan T. Lavavej2019-10-221-1/+1
| | | | (Testing git commit access.)
* [libc++][test] Miscellaneous MSVC cleanupsCasey Carter2019-10-095-66/+64
| | | | | | | | | | | | * Silence unused-local-typedef warnings: `map.cons/assign_initializer_list.pass.cpp` (and the `set.cons` variant) uses a local typedef only within `LIBCPP_ASSERT`s, so clang diagnoses it as unused when testing non-libc++. * Add missing include: `c.math/abs.pass.cpp` uses `std::numeric_limits` but failed to `#include <limits>`. * Don't test non-type: A "recent" change to `meta.trans.other/underlying_type.pass.cpp` unconditionally tests the type `F` which is conditionally defined. * Use `hash<long long>` instead of `hash<short>` with `int` in `unordered_meow` deduction guide tests to avoid truncation warnings. * Convert `3.14` explicitly in `midpoint.float.pass` since MSVC incorrectly diagnoses `float meow = 3.14;` as truncating. Differential Revision: https://reviews.llvm.org/D68681 llvm-svn: 374248
* [libc++] Mark CTAD tests as not failing on AppleClang 10.0.1Louis Dionne2019-09-238-8/+8
| | | | | | They do fail on AppleClang 10.0.0, but not AppleClang 10.0.1 llvm-svn: 372632
* Fix failing negative compilation test for some versions of ClangEric Fiselier2019-09-131-0/+1
| | | | llvm-svn: 371874
* Recommit r370502: Make `vector` unconditionally move elements whenEric Fiselier2019-09-132-45/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exceptions are disabled. The patch was reverted due to some confusion about non-movable types. ie types that explicitly delete their move constructors. However, such types do not meet the requirement for `MoveConstructible`, which is required by `std::vector`: Summary: `std::vector<T>` is free choose between using copy or move operations when it needs to resize. The standard only candidates that the correct exception safety guarantees are provided. When exceptions are disabled these guarantees are trivially satisfied. Meaning vector is free to optimize it's implementation by moving instead of copying. This patch makes `std::vector` unconditionally move elements when exceptions are disabled. This optimization is conforming according to the current standard wording. There are concerns that moving in `-fno-noexceptions`mode will be a surprise to users. For example, a user may be surprised to find their code is slower with exceptions enabled than it is disabled. I'm sympathetic to this surprised, but I don't think it should block this optimization. Reviewers: mclow.lists, ldionne, rsmith Reviewed By: ldionne Subscribers: zoecarver, christof, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D62228 llvm-svn: 371867
* [libc++] Add a test for resizing of a vector with copy-only elementsLouis Dionne2019-09-051-0/+45
| | | | | | See https://reviews.llvm.org/D62228#1658620 llvm-svn: 371067
* libcxx: Rename .hpp files in libcxx/test/support to .hNico Weber2019-08-2139-40/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | LLVM uses .h as its extension for header files. Files renamed using: for f in libcxx/test/support/*.hpp; do git mv $f ${f%.hpp}.h; done References to the files updated using: for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do a=$(basename $f); echo $a; rg -l $a libcxx | xargs sed -i '' "s/$a/${a%.hpp}.h/"; done HPP include guards updated manually using: for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do echo ${f%.hpp}.h ; done | xargs mvim Differential Revision: https://reviews.llvm.org/D66104 llvm-svn: 369481
* [libc++] Add missing UNSUPPORTED for CTAD testsLouis Dionne2019-07-162-0/+2
| | | | | | | The tests for unordered_set and unordered_multiset were missing UNSUPPORTED markup for Apple Clang 9.1, which is still being used on some CI bots. llvm-svn: 366259
* Add contains method to associative containers. This patch implements ↵Zoe Carver2019-07-164-0/+212
| | | | | | P0458R2, adding contains to map, multimap, unordered_map, unordered_multimap, set, multiset, unordered_set, and unordered_multiset. llvm-svn: 366170
* [libc++] Implement P0433: deduction guides for <unordered_map>Louis Dionne2019-07-156-0/+965
| | | | | | | | Thanks to Arthur O'Dwyer for the patch. Differential Revision: https://reviews.llvm.org/D58590 llvm-svn: 366124
* [libc++] Add XFAILs for CTAD tests on older compilersLouis Dionne2019-07-122-0/+2
| | | | llvm-svn: 365923
* Fix memory leak in set and map.Eric Fiselier2019-07-112-10/+53
| | | | | | | | When assigning an initializer list into set/map, libc++ would leak memory if the initializer list contained equivalent keys because we failed to check if the insertion was successful. llvm-svn: 365840
* [libc++] Implement deduction guides for <unordered_set>Louis Dionne2019-07-114-0/+586
| | | | | | | Thanks to Arthur O'Dwyer for the patch. Differential Revision: https://reviews.llvm.org/D58617 llvm-svn: 365788
* Make forward_list::remove/remove_if/unique all return void before C++20; ↵Marshall Clow2019-07-084-62/+124
| | | | | | undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365290
* Make list::remove/remove_if/unique all return void before C++20; undoes that ↵Marshall Clow2019-07-064-19/+84
| | | | | | bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365261
* Implement P0646R1: Erase-Like Algorithms Should Return size_type. Reviewed ↵Marshall Clow2019-07-016-41/+41
| | | | | | as https://reviews.llvm.org/D58332, and then updated because I rewrote a couple of those routines to eliminate some UB. Thanks to Zoe for tghe patch. llvm-svn: 364840
* Fix test failures when using a custom ABI namespace.Richard Smith2019-06-241-2/+2
| | | | llvm-svn: 364239
* [libc++] Take 2: Implement CTAD for map and multimapLouis Dionne2019-06-206-0/+702
| | | | | | | | | | | This is a re-application of r362986 (which was reverted in r363688) with fixes for the issue that caused it to be reverted. Thanks to Arthur O'Dwyer for the patch. Differential Revision: https://reviews.llvm.org/D58587 llvm-svn: 363968
* [libc++] Revert the addition of map/multimap CTADLouis Dionne2019-06-186-702/+0
| | | | | | | | | | | | | This was found to be broken on Clang trunk. This is a revert of the following commits (the subsequent commits added XFAILs to the tests that were missing from the original submission): r362986: Implement deduction guides for map/multimap. r363014: Add some XFAILs r363097: Add more XFAILs r363197: Add even more XFAILs llvm-svn: 363688
* [libcxx] XFAIL set/multiset CTAD tests on Apple Clang 10Louis Dionne2019-06-122-2/+2
| | | | llvm-svn: 363209
* [libcxx] XFAIL some CTAD tests on AppleClang 10Louis Dionne2019-06-122-2/+2
| | | | | | | AppleClang 10 doesn't contain some changes that are required for this test to give the right error message. llvm-svn: 363197
* [libcxx] Mark CTAD tests for set and multiset as unsupported on older Apple ↵Louis Dionne2019-06-112-0/+2
| | | | | | | | Clangs Those fail on Green Dragon. llvm-svn: 363107
* Mark CTAD fail tests for set/multiset as XFAIL for older compilers that give ↵Marshall Clow2019-06-112-0/+4
| | | | | | different error messages llvm-svn: 363099
* XFAIL a couple of tests on apple-clang-9.1, which is a compiler that I ↵Marshall Clow2019-06-112-2/+2
| | | | | | didn't know existed llvm-svn: 363097
* [libc++] Implement deduction guides for <set>Louis Dionne2019-06-114-0/+516
| | | | | | | | | | This is part of C++17's P0433. Thanks to Arthur O'Dwyer for the patch. Differential Revision: https://reviews.llvm.org/D58582 llvm-svn: 363090
* XFAIL a couple of CTAD tests on clang-6; it gives different error messages ↵Marshall Clow2019-06-112-0/+4
| | | | | | than clang 7/8/9 llvm-svn: 363014
* Implement deduction guides for map/multimap. Reviewed as ↵Marshall Clow2019-06-106-0/+698
| | | | | | https://reviews.llvm.org/D58587. Thanks to Quuxplusone for the submission. llvm-svn: 362986
* Add include for 'test_macros.h' to all the tests that were missing them. ↵Marshall Clow2019-05-31565-0/+677
| | | | | | Thanks to Zoe for the (big, but simple) patch. NFC intended. llvm-svn: 362252
* [libcxx][tests] Fix order checking in unordered_multiset tests.Louis Dionne2019-05-235-120/+45
| | | | | | | | | | | | | | | | Some tests assume that iteration through an unordered multiset elements will return them in the same order as at the container creation. This assumption is not true since the container is unordered, so that no specific order of elements is ever guaranteed for such container. This patch introduces checks verifying that any iteration will return elements exactly from a set of valid values and without repetition, but in no particular order. Thanks to Andrey Maksimov for the patch. Differential Revision: https://reviews.llvm.org/D56500 llvm-svn: 361494
* [libcxx][test] Fix order checking in some more unordered_multimap testsLouis Dionne2019-05-2224-858/+643
| | | | | | | | | | | | | | | | Some tests assume that iteration through an unordered multimap elements will return them in the same order as at the container creation. This assumption is not true since the container is unordered, so that no specific order of elements is ever guaranteed for such container. This patch is a continuation of D54838 and introduces checks verifying that any iteration will return elements exactly from a set of valid values and without repetition, but in no particular order. Thanks to Andrey Maksimov for the patch. Differential Revision: https://reviews.llvm.org/D56498 llvm-svn: 361414
* Fix a bunch of unordered container tests that were failing when ↵Marshall Clow2019-05-0118-46/+41
| | | | | | _LIBCPP_DEBUG was set. llvm-svn: 359642
* Add tests specifically for LWG2164. We already did this; but now we have ↵Marshall Clow2019-04-292-0/+23
| | | | | | tests. NFC llvm-svn: 359458
* Add tests for stability to list::sort and forward_list::sort. Thanks to ↵Marshall Clow2019-04-174-0/+184
| | | | | | Jonathan Wakely for the notice llvm-svn: 358541
* Fix list/forward_list implementations of remove_if and unique to deal with ↵Marshall Clow2019-04-164-0/+94
| | | | | | predicates that are part of the sequence passed in. We already do this for remove. llvm-svn: 358534
* [libcxx] [test] Use ptrdiff_t rather than int in splice_after_range.pass.cpp ↵Billy Robert O'Neal III2019-04-031-23/+24
| | | | | | | | to avoid narrowing from pointer subtraction to int warnings. Reviewed as https://reviews.llvm.org/D60104 llvm-svn: 357546
* [libc++] Remove unnecessary <iostream> #includes in testsLouis Dionne2019-03-282-2/+0
| | | | | | | Some tests #include <iostream> but they don't use anything from the header. Those are probably artifacts of when the tests were developped. llvm-svn: 357181
* [libc++] Rename span's as_writeable_bytes to as_writable_bytesLouis Dionne2019-03-283-52/+52
| | | | | | | | | | | | Summary: The Standard says as_writable_bytes. Reviewers: mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D59882 llvm-svn: 357139
* Fix occurrences of _LIBCPP_ASSERT in span testsCasey Carter2019-03-273-8/+8
| | | | llvm-svn: 357092
* Fix a vector test to not use a local type as a template parameter. This ↵Marshall Clow2019-03-221-7/+9
| | | | | | causes a warning on C++03. NFC llvm-svn: 356726
* Mark 'front()' and 'back()' as noexcept for array/deque/string/string_view. ↵Marshall Clow2019-03-192-16/+40
| | | | | | These are just rebranded 'operator[]', and should be noexcept like it is. llvm-svn: 356435
* Update a deque test with more assertions. NFCMarshall Clow2019-03-151-6/+6
| | | | llvm-svn: 356266
* Mark vector::operator[] and front/back as noexcept. We already do this for ↵Marshall Clow2019-03-151-0/+121
| | | | | | string and string_view. This should give better codegen inside of noexcept functions. Add tests for op[]/front/back/at, because apparently we had none. llvm-svn: 356224
* Add noexcept to operator[] for array and deque. This is an extension. We ↵Marshall Clow2019-03-142-4/+29
| | | | | | already do this for string and string_view. This should give better codegen inside of noexcept functions. llvm-svn: 356209
* Eradicate all the ptrdiff_ts in span left over from applying P1227. A couple ↵Marshall Clow2019-03-0611-26/+26
| | | | | | of other minor cleanups. NFC llvm-svn: 355481
OpenPOWER on IntegriCloud