summaryrefslogtreecommitdiffstats
path: root/libcxx/test/strings/basic.string/string.capacity
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/strings/basic.string/string.capacity')
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp58
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp57
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp42
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/length.pass.cpp42
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp73
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/over_max_size.pass.cpp47
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp117
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp79
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp79
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp62
-rw-r--r--libcxx/test/strings/basic.string/string.capacity/size.pass.cpp42
11 files changed, 0 insertions, 698 deletions
diff --git a/libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp
deleted file mode 100644
index bae76215552..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/capacity.pass.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// size_type capacity() const;
-
-#include <string>
-#include <cassert>
-
-#include "test_allocator.h"
-#include "min_allocator.h"
-
-template <class S>
-void
-test(S s)
-{
- S::allocator_type::throw_after = 0;
- try
- {
- while (s.size() < s.capacity())
- s.push_back(typename S::value_type());
- assert(s.size() == s.capacity());
- }
- catch (...)
- {
- assert(false);
- }
- S::allocator_type::throw_after = INT_MAX;
-}
-
-int main()
-{
- {
- typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S;
- S s;
- test(s);
- s.assign(10, 'a');
- s.erase(5);
- test(s);
- s.assign(100, 'a');
- s.erase(50);
- test(s);
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s;
- assert(s.capacity() > 0);
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp
deleted file mode 100644
index b73af759934..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/clear.pass.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void clear();
-
-#include <string>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(S s)
-{
- s.clear();
- assert(s.size() == 0);
-}
-
-int main()
-{
- {
- typedef std::string S;
- S s;
- test(s);
-
- s.assign(10, 'a');
- s.erase(5);
- test(s);
-
- s.assign(100, 'a');
- s.erase(50);
- test(s);
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s;
- test(s);
-
- s.assign(10, 'a');
- s.erase(5);
- test(s);
-
- s.assign(100, 'a');
- s.erase(50);
- test(s);
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp
deleted file mode 100644
index ac65f514485..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/empty.pass.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// bool empty() const;
-
-#include <string>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(const S& s)
-{
- assert(s.empty() == (s.size() == 0));
-}
-
-int main()
-{
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/length.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/length.pass.cpp
deleted file mode 100644
index d3ae1aaee03..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/length.pass.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// size_type length() const;
-
-#include <string>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(const S& s)
-{
- assert(s.length() == s.size());
-}
-
-int main()
-{
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp
deleted file mode 100644
index f42642563bd..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/max_size.pass.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// size_type max_size() const;
-
-// NOTE: asan and msan will fail for one of two reasons
-// 1. If allocator_may_return_null=0 then they will fail because the allocation
-// returns null.
-// 2. If allocator_may_return_null=1 then they will fail because the allocation
-// is too large to succeed.
-// UNSUPPORTED: asan, msan
-
-#include <string>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test1(const S& s)
-{
- S s2(s);
- const size_t sz = s2.max_size() - 1;
- try { s2.resize(sz, 'x'); }
- catch ( const std::bad_alloc & ) { return ; }
- assert ( s2.size() == sz );
-}
-
-template <class S>
-void
-test2(const S& s)
-{
- S s2(s);
- const size_t sz = s2.max_size();
- try { s2.resize(sz, 'x'); }
- catch ( const std::bad_alloc & ) { return ; }
- assert ( s.size() == sz );
-}
-
-template <class S>
-void
-test(const S& s)
-{
- assert(s.max_size() >= s.size());
- test1(s);
- test2(s);
-}
-
-int main()
-{
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/over_max_size.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/over_max_size.pass.cpp
deleted file mode 100644
index bbadb9ccc5a..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/over_max_size.pass.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// size_type max_size() const;
-
-#include <string>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(const S& s)
-{
- assert(s.max_size() >= s.size());
- S s2(s);
- const size_t sz = s2.max_size() + 1;
- try { s2.resize(sz, 'x'); }
- catch ( const std::length_error & ) { return ; }
- assert ( false );
-}
-
-int main()
-{
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp
deleted file mode 100644
index a155825be75..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/reserve.pass.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void reserve(size_type res_arg=0);
-
-#include <string>
-#include <stdexcept>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(S s)
-{
- typename S::size_type old_cap = s.capacity();
- S s0 = s;
- s.reserve();
- assert(s.__invariants());
- assert(s == s0);
- assert(s.capacity() <= old_cap);
- assert(s.capacity() >= s.size());
-}
-
-template <class S>
-void
-test(S s, typename S::size_type res_arg)
-{
- typename S::size_type old_cap = s.capacity();
- S s0 = s;
- try
- {
- s.reserve(res_arg);
- assert(res_arg <= s.max_size());
- assert(s == s0);
- assert(s.capacity() >= res_arg);
- assert(s.capacity() >= s.size());
- }
- catch (std::length_error&)
- {
- assert(res_arg > s.max_size());
- }
-}
-
-int main()
-{
- {
- typedef std::string S;
- {
- S s;
- test(s);
-
- s.assign(10, 'a');
- s.erase(5);
- test(s);
-
- s.assign(100, 'a');
- s.erase(50);
- test(s);
- }
- {
- S s;
- test(s, 5);
- test(s, 10);
- test(s, 50);
- }
- {
- S s(100, 'a');
- s.erase(50);
- test(s, 5);
- test(s, 10);
- test(s, 50);
- test(s, 100);
- test(s, S::npos);
- }
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- {
- S s;
- test(s);
-
- s.assign(10, 'a');
- s.erase(5);
- test(s);
-
- s.assign(100, 'a');
- s.erase(50);
- test(s);
- }
- {
- S s;
- test(s, 5);
- test(s, 10);
- test(s, 50);
- }
- {
- S s(100, 'a');
- s.erase(50);
- test(s, 5);
- test(s, 10);
- test(s, 50);
- test(s, 100);
- test(s, S::npos);
- }
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp
deleted file mode 100644
index 14fe209fd59..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/resize_size.pass.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void resize(size_type n);
-
-#include <string>
-#include <stdexcept>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(S s, typename S::size_type n, S expected)
-{
- try
- {
- s.resize(n);
- assert(s.__invariants());
- assert(n <= s.max_size());
- assert(s == expected);
- }
- catch (std::length_error&)
- {
- assert(n > s.max_size());
- }
-}
-
-int main()
-{
- {
- typedef std::string S;
- test(S(), 0, S());
- test(S(), 1, S(1, '\0'));
- test(S(), 10, S(10, '\0'));
- test(S(), 100, S(100, '\0'));
- test(S("12345"), 0, S());
- test(S("12345"), 2, S("12"));
- test(S("12345"), 5, S("12345"));
- test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
- test(S("12345678901234567890123456789012345678901234567890"), 0, S());
- test(S("12345678901234567890123456789012345678901234567890"), 10,
- S("1234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 50,
- S("12345678901234567890123456789012345678901234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 60,
- S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
- test(S(), S::npos, S("not going to happen"));
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(), 0, S());
- test(S(), 1, S(1, '\0'));
- test(S(), 10, S(10, '\0'));
- test(S(), 100, S(100, '\0'));
- test(S("12345"), 0, S());
- test(S("12345"), 2, S("12"));
- test(S("12345"), 5, S("12345"));
- test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
- test(S("12345678901234567890123456789012345678901234567890"), 0, S());
- test(S("12345678901234567890123456789012345678901234567890"), 10,
- S("1234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 50,
- S("12345678901234567890123456789012345678901234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 60,
- S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
- test(S(), S::npos, S("not going to happen"));
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp
deleted file mode 100644
index f293df971f2..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void resize(size_type n, charT c);
-
-#include <string>
-#include <stdexcept>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(S s, typename S::size_type n, typename S::value_type c, S expected)
-{
- try
- {
- s.resize(n, c);
- assert(s.__invariants());
- assert(n <= s.max_size());
- assert(s == expected);
- }
- catch (std::length_error&)
- {
- assert(n > s.max_size());
- }
-}
-
-int main()
-{
- {
- typedef std::string S;
- test(S(), 0, 'a', S());
- test(S(), 1, 'a', S("a"));
- test(S(), 10, 'a', S(10, 'a'));
- test(S(), 100, 'a', S(100, 'a'));
- test(S("12345"), 0, 'a', S());
- test(S("12345"), 2, 'a', S("12"));
- test(S("12345"), 5, 'a', S("12345"));
- test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
- test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
- test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
- S("1234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
- S("12345678901234567890123456789012345678901234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
- S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
- test(S(), S::npos, 'a', S("not going to happen"));
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(), 0, 'a', S());
- test(S(), 1, 'a', S("a"));
- test(S(), 10, 'a', S(10, 'a'));
- test(S(), 100, 'a', S(100, 'a'));
- test(S("12345"), 0, 'a', S());
- test(S("12345"), 2, 'a', S("12"));
- test(S("12345"), 5, 'a', S("12345"));
- test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
- test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
- test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
- S("1234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
- S("12345678901234567890123456789012345678901234567890"));
- test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
- S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
- test(S(), S::npos, 'a', S("not going to happen"));
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
deleted file mode 100644
index aacbffd098f..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void shrink_to_fit();
-
-#include <string>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(S s)
-{
- typename S::size_type old_cap = s.capacity();
- S s0 = s;
- s.shrink_to_fit();
- assert(s.__invariants());
- assert(s == s0);
- assert(s.capacity() <= old_cap);
- assert(s.capacity() >= s.size());
-}
-
-int main()
-{
- {
- typedef std::string S;
- S s;
- test(s);
-
- s.assign(10, 'a');
- s.erase(5);
- test(s);
-
- s.assign(100, 'a');
- s.erase(50);
- test(s);
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s;
- test(s);
-
- s.assign(10, 'a');
- s.erase(5);
- test(s);
-
- s.assign(100, 'a');
- s.erase(50);
- test(s);
- }
-#endif
-}
diff --git a/libcxx/test/strings/basic.string/string.capacity/size.pass.cpp b/libcxx/test/strings/basic.string/string.capacity/size.pass.cpp
deleted file mode 100644
index 21b475a8113..00000000000
--- a/libcxx/test/strings/basic.string/string.capacity/size.pass.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// size_type size() const;
-
-#include <string>
-#include <cassert>
-
-#include "min_allocator.h"
-
-template <class S>
-void
-test(const S& s, typename S::size_type c)
-{
- assert(s.size() == c);
-}
-
-int main()
-{
- {
- typedef std::string S;
- test(S(), 0);
- test(S("123"), 3);
- test(S("12345678901234567890123456789012345678901234567890"), 50);
- }
-#if __cplusplus >= 201103L
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(), 0);
- test(S("123"), 3);
- test(S("12345678901234567890123456789012345678901234567890"), 50);
- }
-#endif
-}
OpenPOWER on IntegriCloud