summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/strings/basic.string/string.cons
Commit message (Collapse)AuthorAgeFilesLines
* libcxx: Rename .hpp files in libcxx/test/support to .hNico Weber2019-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add include for 'test_macros.h' to all the tests that were missing them. ↵Marshall Clow2019-05-312-0/+2
| | | | | | Thanks to Zoe for the (big, but simple) patch. NFC intended. llvm-svn: 362252
* [libcxx] [test] Fix test bugs in string.cons/copy_alloc.pass.cpp.Billy Robert O'Neal III2019-04-031-6/+7
| | | | | | | | | | | | | | Fixed the inability to properly rebind the testing allocator, by making the inner alloc_impl type a plain struct and making the operations templates. Before rebind failed to compile complaining that a alloc_impl<T>* was not convertible to an alloc_impl<U>*. This enables the test to pass for MSVC++ once we provide the strong guarantee for the copy assignment operator. Reviewed as https://reviews.llvm.org/D60023 llvm-svn: 357545
* Properly constrain basic_string(Iter, Iter, Alloc = A())Eric Fiselier2019-03-141-0/+9
| | | | llvm-svn: 356140
* [libc++] Mark several tests as XFAIL on macosx10.7Louis Dionne2019-02-271-0/+5
| | | | | | | | | | | | | | | Those tests fail when linking against a new dylib but running against macosx10.7. I believe this is caused by a duplicate definition of the RTTI for exception classes in libc++.dylib and libc++abi.dylib, but this matter still needs some investigation. This issue was not caught previously because all the tests always linked against the same dylib used for running (because LIT made it impossible to do otherwise before r349171). rdar://problem/46809586 llvm-svn: 354940
* Support tests in freestandingJF Bastien2019-02-0432-32/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Freestanding is *weird*. The standard allows it to differ in a bunch of odd manners from regular C++, and the committee would like to improve that situation. I'd like to make libc++ behave better with what freestanding should be, so that it can be a tool we use in improving the standard. To do that we need to try stuff out, both with "freestanding the language mode" and "freestanding the library subset". Let's start with the super basic: run the libc++ tests in freestanding, using clang as the compiler, and see what works. The easiest hack to do this: In utils/libcxx/test/config.py add: self.cxx.compile_flags += ['-ffreestanding'] Run the tests and they all fail. Why? Because in freestanding `main` isn't special. This "not special" property has two effects: main doesn't get mangled, and main isn't allowed to omit its `return` statement. The first means main gets mangled and the linker can't create a valid executable for us to test. The second means we spew out warnings (ew) and the compiler doesn't insert the `return` we omitted, and main just falls of the end and does whatever undefined behavior (if you're luck, ud2 leading to non-zero return code). Let's start my work with the basics. This patch changes all libc++ tests to declare `main` as `int main(int, char**` so it mangles consistently (enabling us to declare another `extern "C"` main for freestanding which calls the mangled one), and adds `return 0;` to all places where it was missing. This touches 6124 files, and I apologize. The former was done with The Magic Of Sed. The later was done with a (not quite correct but decent) clang tool: https://gist.github.com/jfbastien/793819ff360baa845483dde81170feed This works for most tests, though I did have to adjust a few places when e.g. the test runs with `-x c`, macros are used for main (such as for the filesystem tests), etc. Once this is in we can create a freestanding bot which will prevent further regressions. After that, we can start the real work of supporting C++ freestanding fairly well in libc++. <rdar://problem/47754795> Reviewers: ldionne, mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, arphaman, miyuki, libcxx-commits Differential Revision: https://reviews.llvm.org/D57624 llvm-svn: 353086
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1932-128/+96
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Second part of P0482 - char8_t. Reviewed as https://reviews.llvm.org/D55308Marshall Clow2018-12-112-0/+24
| | | | llvm-svn: 348828
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2018-11-142-2/+2
| | | | llvm-svn: 346826
* Implement LWG 2946, 3075 and 3076. Reviewed as https://reviews.llvm.org/D48616Marshall Clow2018-07-0211-37/+343
| | | | llvm-svn: 336132
* [libcxx] [test] Mark the test as unsupported by apple-clang-8.1.Volodymyr Sapsai2018-05-221-1/+1
| | | | llvm-svn: 333011
* [libcxx][test] Adding apple-clang-9 to UNSUPPORTED in ↵Mike Edwards2018-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | iter_alloc_deduction.fail.cpp. After two failed attempts last week to make this work I am going back to a known good method of making this test pass on macOS...adding the current apple-clang version to the UNSUPPORTED list. During a previous patch review (https://reviews.llvm.org/D44103) it was suggested to just XFAIL libcpp-no-deduction-guides as was done to iter_alloc_deduction.pass.cpp. However this caused a an unexpected pass on: http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std/builds/214 I then attempted to just mark libcpp-no-deduction-guides as UNSUPPORTED, however this caused an additional bot failure. So I reverted everything (https://reviews.llvm.org/rCXX327191). To solve this and get work unblocked I am adding apple-clang-9 to the original UNSUPPORTED list. llvm-svn: 327304
* [libcxx][test] Reverting r327178 and r327190.Mike Edwards2018-03-101-1/+2
| | | | | | | Reverting changes made to iter_alloc_deduction.fail.cpp as my changes seem to be making several Linux bots angry. llvm-svn: 327191
* [libcxx][test] Marking libcpp-no-deduction-guides unsupported.Mike Edwards2018-03-101-1/+1
| | | | | | This fixes linux bot failures with r327178. llvm-svn: 327190
* XFAIL: libcpp-no-deduction-guides in ↵Mike Edwards2018-03-091-2/+1
| | | | | | | | | | | | | | | | libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp Summary: Refactor the previous version method of marking each apple-clang version as UNSUPPORTED and just XFAIL'ing the libcpp-no-deduction-guides instead. This brings this test inline with the same style as iter_alloc_deduction.pass.cpp Reviewers: EricWF, dexonsmith Reviewed By: EricWF Subscribers: EricWF, vsapsai, vsk, cfe-commits Differential Revision: https://reviews.llvm.org/D44103 llvm-svn: 327178
* Add another test case to the deduction guide for basic_string.Marshall Clow2018-02-221-0/+11
| | | | llvm-svn: 325740
* Fix test failure on compilers w/o deduction guidesEric Fiselier2018-02-151-2/+1
| | | | llvm-svn: 325205
* The apple versions of clang don't support deduction guides yet.Marshall Clow2018-02-082-0/+2
| | | | llvm-svn: 324640
* Once more, with feeling. Spell 'clang-4.0' correctly this timeMarshall Clow2018-02-082-2/+2
| | | | llvm-svn: 324624
* Clean up string's deduction guides tests. Mark old versions of clang as ↵Marshall Clow2018-02-083-58/+83
| | | | | | unsupported, b/c they don't have deduction guides, even in C++17 mode llvm-svn: 324619
* Temporarily comment out deduction guide tests while I figure out what to do ↵Marshall Clow2018-02-082-0/+3
| | | | | | with old bots llvm-svn: 324573
* Implement deduction guide for basic_string as described in P0433Marshall Clow2018-02-082-0/+110
| | | | llvm-svn: 324569
* Another missing string_view testMarshall Clow2017-09-071-0/+74
| | | | llvm-svn: 312691
* [libcxx] [test] Untabify, NFC.Stephan T. Lavavej2017-07-295-32/+32
| | | | llvm-svn: 309464
* Fix possible loss of data warnings on amd64Billy Robert O'Neal III2017-05-081-8/+10
| | | | | | | | | | | | | In T_size_size.pass, there is an explicit template argument to std::min to ask for unsigned, to avoid type deduction errors. However, C1XX' warnings still hate this use, because a 64 bit value (a size_t) is being passed to a function accepting an unsigned (a 32 bit value). Instead, change the tests to pass around std::size_t instances, and explicitly narrow when constructing the string type under test. This also allows removal of explicit template arguments to std::min. llvm-svn: 302473
* Resolve unused local typedef warning in test.Billy Robert O'Neal III2017-04-211-1/+0
| | | | llvm-svn: 300937
* Remove XFAIL in implicit_deduction_guides testsSteven Wu2017-02-271-4/+0
| | | | | | | | The clang assertion causing these tests failing with sanitizer is fixed in r295794. All the bots running libcxx tests should be upgraded and running the compiler with the fix. llvm-svn: 296385
* Work around Clang assertion when testing C++17 deduction guides with '-g'.Eric Fiselier2017-02-171-0/+4
| | | | llvm-svn: 295417
* [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible ↵Eric Fiselier2017-02-171-0/+300
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parameter types. Summary: This patch fixes http://llvm.org/PR31938. The description below is copy/pasted from the bug: The standard says: template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>> class basic_string { using value_type = typename traits::char_type; // ... basic_string(const charT* s, const Allocator& a = Allocator()); }; libc++ actually chooses to declare the constructor as basic_string(const value_type* s, const Allocator& a = Allocator()); The implicit deduction guides from class template argument deduction make what was previously an implementation detail visible: std::basic_string s = "foo"; // error, can't deduce charT. The constructor in question is in the libc++ DSO, but fortunately it looks like fixing this will not result in an ABI break. @rsmith How does this look? I did more than just the constructors mentioned in the PR, but IDK how far to take it. Reviewers: mclow.lists, rsmith Reviewed By: rsmith Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D29863 llvm-svn: 295393
* [libcxx] [test] Strip trailing whitespace.Stephan T. Lavavej2017-02-051-3/+3
| | | | | | No functional change, no code review. llvm-svn: 294161
* [libcxx] [test] Fix Clang -Wunused-local-typedef, part 2/3.Stephan T. Lavavej2017-02-055-13/+0
| | | | | | | | These typedefs were completely unused. Fixes D29136. llvm-svn: 294155
* [libcxx] [test] Fix Clang -Wunused-local-typedef, part 1/3.Stephan T. Lavavej2017-02-051-1/+3
| | | | | | | | | | | | | | | | | Guard typedefs and static_asserts with _LIBCPP_VERSION. test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp Additionally deal with conditional compilation. test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp Additionally deal with typedefs used by other typedefs. Fixes D29135. llvm-svn: 294154
* Fix up some no-exception compile failuresMarshall Clow2017-01-311-11/+11
| | | | llvm-svn: 293623
* Workaround new -Wshadow warning introduced by r293599Alex Lorenz2017-01-311-1/+1
| | | | llvm-svn: 293619
* Fix PR#31779: basic_string::operator= isn't exception safe.Marshall Clow2017-01-311-0/+81
| | | | llvm-svn: 293599
* Fix std::string assignment ambiguity from braced initializer lists.Eric Fiselier2017-01-172-0/+58
| | | | | | | | | | When support for `basic_string_view` was added to string it also added new assignment operators from `basic_string_view`. These caused ambiguity when assigning from a braced initializer. This patch fixes that regression by making the basic_string_view assignment operator rank lower in overload resolution by making it a template. llvm-svn: 292276
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | loss of data", part 7/7. test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp Add static_cast<char> because basic_istream::get() returns int_type (N4606 27.7.2.3 [istream.unformatted]/4). test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp Add static_cast<char> because toupper() returns int (C11 7.4.2.2/1). test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp This test is intentionally writing doubles to ostream_iterator<int>. It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing for MSVC. test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp Given `extern float zero;`, the expression `1./zero` has type double, which emits a truncation warning when being passed to test<float>() taking float. The fix is to say `1.f/zero` which has type float. test/std/numerics/complex.number/cmplx.over/arg.pass.cpp test/std/numerics/complex.number/cmplx.over/norm.pass.cpp These tests were constructing std::complex<double>(x, 0), emitting truncation warnings when x is long long. Saying static_cast<double>(x) avoids this. test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp This was using `int s` to construct and seed a linear_congruential_engine<T, stuff>, where T is unsigned short/unsigned int/unsigned long/unsigned long long. That emits a truncation warning in the unsigned short case. Because the range [0, 20) is tiny and we aren't doing anything else with the index, we can just iterate with `T s`. test/std/re/re.traits/value.pass.cpp regex_traits<wchar_t>::value()'s first parameter is wchar_t (N4606 28.7 [re.traits]/13). This loop is using int to iterate through ['g', 0xFFFF), emitting a truncation warning from int to wchar_t (which is 16-bit for some of us). Because the bound is exclusive, we can just iterate with wchar_t. test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp This test is a little strange. It's trying to verify that basic_string's (InIt, InIt) range constructor isn't confused by "N copies of C" when N and C have the same integral type. To do this, it was testing (100, 65), but that eventually emits truncation warnings from int to char. There's a simple way to avoid this - passing (static_cast<char>(100), static_cast<char>(65)) also exercises the disambiguation. (And 100 is representable even when char has a signed range.) test/std/strings/string.view/string.view.hash/string_view.pass.cpp Add static_cast<char_type> because `'0' + i` has type int. test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp What's more horrible than nested bind()? pow() overloads! This operator()(T a, T b) was assuming that std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 26.9.1 [cmath.syn]/2 says that pow(int, int) returns double, so this was truncating double to int. Adding static_cast<T> silences this. test/std/utilities/function.objects/unord.hash/integral.pass.cpp This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` but that's truncating when T is short. (And super truncating when T is bool.) Adding static_cast<T> silences this. test/std/utilities/utility/exchange/exchange.pass.cpp First, this was exchanging 67.2 into an int, but that's inherently truncating. Changing this to static_cast<short>(67) avoids the truncation while preserving the "what if T and U are different" test coverage. Second, this was exchanging {} with the explicit type float into an int, and that's also inherently truncating. Specifying short is just as good. test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp Add static_cast<short>. Note that this affects template argument deduction for make_pair(), better fulfilling the test's intent. For example, this was saying `typedef std::pair<int, short> P1; P1 p1 = std::make_pair(3, 4);` but that was asking make_pair() to return pair<int, int>, which was then being converted to pair<int, short>. (pair's converting constructors are tested elsewhere.) Now, std::make_pair(3, static_cast<short>(4)) actually returns pair<int, short>. (There's still a conversion from pair<nullptr_t, short> to pair<unique_ptr<int>, short>.) Fixes D27544. llvm-svn: 289111
* [libcxx] [test] D27269: Fix MSVC x64 warning C4267 "conversion from 'size_t' ↵Stephan T. Lavavej2016-12-062-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | to 'int' [or 'unsigned int'], possible loss of data", part 3/4. test/std/containers/sequences/vector.bool/copy.pass.cpp test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp test/std/containers/sequences/vector/vector.cons/copy.pass.cpp test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp Change "unsigned s = x.size();" to "typename C::size_type s = x.size();" because that's what it returns. test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp Include <cstddef>, then change "unsigned n = T::length(s);" to "std::size_t n = T::length(s);" because that's what char_traits returns. test/std/strings/basic.string/string.cons/substr.pass.cpp Change unsigned to typename S::size_type because that's what str.size() returns. test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp This was needlessly truncating std::size_t to unsigned. It's being used to compare and initialize std::size_t. llvm-svn: 288753
* [libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-061-2/+3
| | | | | | | | | | 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
* [libcxx] [test] D27021: Fix MSVC warning C4389 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-12-061-2/+3
| | | | | | | | | | | | | | | | | | | | | part 8/12. Add static_cast<std::size_t> when comparing distance() to size(). These replacements were performed programmatically with regex_replace(): const vector<pair<regex, string>> reg_fmt = { { regex(R"(assert\((\w+)\.size\(\) == std::distance\((\w+, \w+)\)\))"), "assert($1.size() == static_cast<std::size_t>(std::distance($2)))" }, { regex(R"(assert\(distance\((\w+\.begin\(\), \w+\.end\(\))\) == (\w+)\.size\(\)\))"), "assert(static_cast<std::size_t>(distance($1)) == $2.size())" }, { regex(R"(assert\(std::distance\((\w+\.\w*begin\(\), \w+\.\w*end\(\))\) == (\w+)\.size\(\)\))"), "assert(static_cast<std::size_t>(std::distance($1)) == $2.size())" }, }; Also, include <cstddef> when it wasn't already being included. llvm-svn: 288745
* [libcxx] [test] D27027: Strip trailing whitespace.Stephan T. Lavavej2016-11-231-1/+1
| | | | llvm-svn: 287829
* [libcxx] [test] D27018: Fix MSVC warning C4018 "signed/unsigned mismatch", ↵Stephan T. Lavavej2016-11-231-2/+2
| | | | | | | | | | | | | | | | | | | 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
* Missed one of the try blocks the first time :-(. Thanks to Renato for the ↵Marshall Clow2016-11-151-3/+13
| | | | | | heads up. llvm-svn: 286932
* Missed a test with exceptions disabled earlier. Oops.Marshall Clow2016-11-141-4/+14
| | | | llvm-svn: 286883
* Fixes for LWG 2598, 2686, 2739, 2742, 2747, and 2759, which were adopted ↵Marshall Clow2016-11-141-0/+166
| | | | | | last week in Issaquah llvm-svn: 286858
* Protect exceptional paths under libcpp-no-exceptionsRoger Ferrer Ibanez2016-11-011-13/+45
| | | | | | | | | | | | | | | | | | | | | | These tests are of the form try { action-that-may-throw assert(!exceptional-condition) assert(some-other-facts) } catch (relevant-exception) { assert(exceptional-condition) } Under libcpp-no-exceptions there is still value in verifying some-other-facts while avoiding the exceptional case. So for these tests just conditionally check some-other-facts if exceptional-condition is false. When exception are supported make sure that a true exceptional-condition throws an exception Differential Revision: https://reviews.llvm.org/D26136 llvm-svn: 285697
* Fix _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to always have default visibility.Eric Fiselier2016-10-311-0/+5
| | | | | | | | | | | This prevent the symbols from being both externally available and hidden, which causes them to be linked incorrectly. This is only a problem when the address of the function is explicitly taken since it will always be inlined otherwise. This patch fixes the issues that caused r285456 to be reverted, and can now be reapplied. llvm-svn: 285531
* Support allocators with explicit conversion constructors. Fixes bug #29000Marshall Clow2016-08-171-0/+1
| | | | llvm-svn: 278904
* Make dtor_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.comEric Fiselier2016-07-251-1/+2
| | | | llvm-svn: 276595
* Implement std::string_view as described in http://wg21.link/P0254R1. ↵Marshall Clow2016-07-212-0/+112
| | | | | | Reviewed as https://reviews.llvm.org/D21459 llvm-svn: 276238
OpenPOWER on IntegriCloud