diff options
author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
commit | a90c6dd46005b2b14de3bb889a8d03bb34bd3256 (patch) | |
tree | 81065ae44967d68964de1f2fdfa107623e58e8a4 /test/std/strings/basic.string/string.modifiers/string_op_plus_equal | |
parent | 669a8a5a1929e881258bfed10d7461ca42ea0a9e (diff) | |
download | external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.tar.gz external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.tar.bz2 external_libcxx-a90c6dd46005b2b14de3bb889a8d03bb34bd3256.zip |
Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/strings/basic.string/string.modifiers/string_op_plus_equal')
4 files changed, 239 insertions, 0 deletions
diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp new file mode 100644 index 000000000..7384ae7f1 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// basic_string<charT,traits,Allocator>& operator+=(charT c); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, typename S::value_type str, S expected) +{ + s += str; + assert(s.__invariants()); + assert(s == expected); +} + +int main() +{ + { + typedef std::string S; + test(S(), 'a', S("a")); + test(S("12345"), 'a', S("12345a")); + test(S("1234567890"), 'a', S("1234567890a")); + test(S("12345678901234567890"), 'a', S("12345678901234567890a")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), 'a', S("a")); + test(S("12345"), 'a', S("12345a")); + test(S("1234567890"), 'a', S("1234567890a")); + test(S("12345678901234567890"), 'a', S("12345678901234567890a")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp new file mode 100644 index 000000000..c29102899 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// basic_string& operator+=(initializer_list<charT> il); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + { + std::string s("123"); + s += {'a', 'b', 'c'}; + assert(s == "123abc"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s("123"); + s += {'a', 'b', 'c'}; + assert(s == "123abc"); + } +#endif +#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +} diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp new file mode 100644 index 000000000..77b20d1bc --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// basic_string<charT,traits,Allocator>& operator+=(const charT* s); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, const typename S::value_type* str, S expected) +{ + s += str; + assert(s.__invariants()); + assert(s == expected); +} + +int main() +{ + { + typedef std::string S; + test(S(), "", S()); + test(S(), "12345", S("12345")); + test(S(), "1234567890", S("1234567890")); + test(S(), "12345678901234567890", S("12345678901234567890")); + + test(S("12345"), "", S("12345")); + test(S("12345"), "12345", S("1234512345")); + test(S("12345"), "1234567890", S("123451234567890")); + test(S("12345"), "12345678901234567890", S("1234512345678901234567890")); + + test(S("1234567890"), "", S("1234567890")); + test(S("1234567890"), "12345", S("123456789012345")); + test(S("1234567890"), "1234567890", S("12345678901234567890")); + test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890")); + + test(S("12345678901234567890"), "", S("12345678901234567890")); + test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); + test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890")); + test(S("12345678901234567890"), "12345678901234567890", + S("1234567890123456789012345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), "", S()); + test(S(), "12345", S("12345")); + test(S(), "1234567890", S("1234567890")); + test(S(), "12345678901234567890", S("12345678901234567890")); + + test(S("12345"), "", S("12345")); + test(S("12345"), "12345", S("1234512345")); + test(S("12345"), "1234567890", S("123451234567890")); + test(S("12345"), "12345678901234567890", S("1234512345678901234567890")); + + test(S("1234567890"), "", S("1234567890")); + test(S("1234567890"), "12345", S("123456789012345")); + test(S("1234567890"), "1234567890", S("12345678901234567890")); + test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890")); + + test(S("12345678901234567890"), "", S("12345678901234567890")); + test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); + test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890")); + test(S("12345678901234567890"), "12345678901234567890", + S("1234567890123456789012345678901234567890")); + } +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp new file mode 100644 index 000000000..336497925 --- /dev/null +++ b/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// basic_string<charT,traits,Allocator>& +// operator+=(const basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s, S str, S expected) +{ + s += str; + assert(s.__invariants()); + assert(s == expected); +} + +int main() +{ + { + typedef std::string S; + test(S(), S(), S()); + test(S(), S("12345"), S("12345")); + test(S(), S("1234567890"), S("1234567890")); + test(S(), S("12345678901234567890"), S("12345678901234567890")); + + test(S("12345"), S(), S("12345")); + test(S("12345"), S("12345"), S("1234512345")); + test(S("12345"), S("1234567890"), S("123451234567890")); + test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); + + test(S("1234567890"), S(), S("1234567890")); + test(S("1234567890"), S("12345"), S("123456789012345")); + test(S("1234567890"), S("1234567890"), S("12345678901234567890")); + test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); + + test(S("12345678901234567890"), S(), S("12345678901234567890")); + test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); + test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); + test(S("12345678901234567890"), S("12345678901234567890"), + S("1234567890123456789012345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(), S(), S()); + test(S(), S("12345"), S("12345")); + test(S(), S("1234567890"), S("1234567890")); + test(S(), S("12345678901234567890"), S("12345678901234567890")); + + test(S("12345"), S(), S("12345")); + test(S("12345"), S("12345"), S("1234512345")); + test(S("12345"), S("1234567890"), S("123451234567890")); + test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); + + test(S("1234567890"), S(), S("1234567890")); + test(S("1234567890"), S("12345"), S("123456789012345")); + test(S("1234567890"), S("1234567890"), S("12345678901234567890")); + test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); + + test(S("12345678901234567890"), S(), S("12345678901234567890")); + test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); + test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); + test(S("12345678901234567890"), S("12345678901234567890"), + S("1234567890123456789012345678901234567890")); + } +#endif +} |