libcxx initial import

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/strings/basic.string/string.cons/alloc.pass.cpp b/test/strings/basic.string/string.cons/alloc.pass.cpp
new file mode 100644
index 0000000..f015f6a
--- /dev/null
+++ b/test/strings/basic.string/string.cons/alloc.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// explicit basic_string(const Allocator& a = Allocator());
+
+#include <string>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+template <class S>
+void
+test()
+{
+    {
+    S s;
+    assert(s.__invariants());
+    assert(s.data());
+    assert(s.size() == 0);
+    assert(s.capacity() >= s.size());
+    assert(s.get_allocator() == typename S::allocator_type());
+    }
+    {
+    S s(typename S::allocator_type(5));
+    assert(s.__invariants());
+    assert(s.data());
+    assert(s.size() == 0);
+    assert(s.capacity() >= s.size());
+    assert(s.get_allocator() == typename S::allocator_type(5));
+    }
+}
+
+int main()
+{
+    test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
+}
diff --git a/test/strings/basic.string/string.cons/char_assignment.pass.cpp b/test/strings/basic.string/string.cons/char_assignment.pass.cpp
new file mode 100644
index 0000000..b945b1b
--- /dev/null
+++ b/test/strings/basic.string/string.cons/char_assignment.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& operator=(charT c);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s1, typename S::value_type s2)
+{
+    typedef typename S::traits_type T;
+    s1 = s2;
+    assert(s1.__invariants());
+    assert(s1.size() == 1);
+    assert(T::eq(s1[0], s2));
+    assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), 'a');
+    test(S("1"), 'a');
+    test(S("123456789"), 'a');
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
+}
diff --git a/test/strings/basic.string/string.cons/copy.pass.cpp b/test/strings/basic.string/string.cons/copy.pass.cpp
new file mode 100644
index 0000000..2c68fbd
--- /dev/null
+++ b/test/strings/basic.string/string.cons/copy.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+template <class S>
+void
+test(S s1)
+{
+    S s2 = s1;
+    assert(s2.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == s1.get_allocator());
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(A(3)));
+    test(S("1", A(5)));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+}
diff --git a/test/strings/basic.string/string.cons/copy_alloc.pass.cpp b/test/strings/basic.string/string.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..00763cd
--- /dev/null
+++ b/test/strings/basic.string/string.cons/copy_alloc.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string& str, const Allocator& alloc);
+
+#include <string>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+template <class S>
+void
+test(S s1, const typename S::allocator_type& a)
+{
+    S s2(s1, a);
+    assert(s2.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == a);
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(), A(3));
+    test(S("1"), A(5));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+}
diff --git a/test/strings/basic.string/string.cons/copy_assignment.pass.cpp b/test/strings/basic.string/string.cons/copy_assignment.pass.cpp
new file mode 100644
index 0000000..9756607
--- /dev/null
+++ b/test/strings/basic.string/string.cons/copy_assignment.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& 
+//   operator=(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s1, const S& s2)
+{
+    s1 = s2;
+    assert(s1.__invariants());
+    assert(s1 == s2);
+    assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), S());
+    test(S("1"), S());
+    test(S(), S("1"));
+    test(S("1"), S("2"));
+    test(S("1"), S("2"));
+
+    test(S(),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("123456789"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+}
diff --git a/test/strings/basic.string/string.cons/initializer_list.pass.cpp b/test/strings/basic.string/string.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..1e4e8a4
--- /dev/null
+++ b/test/strings/basic.string/string.cons/initializer_list.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
+
+#include <string>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s = {'a', 'b', 'c'};
+        assert(s == "abc");
+    }
+    {
+        std::wstring s;
+        s = {L'a', L'b', L'c'};
+        assert(s == L"abc");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp b/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
new file mode 100644
index 0000000..d7686a3
--- /dev/null
+++ b/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& operator=(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    {
+        std::string s;
+        s = {'a', 'b', 'c'};
+        assert(s == "abc");
+    }
+#endif
+}
diff --git a/test/strings/basic.string/string.cons/iter_alloc.pass.cpp b/test/strings/basic.string/string.cons/iter_alloc.pass.cpp
new file mode 100644
index 0000000..752fb33
--- /dev/null
+++ b/test/strings/basic.string/string.cons/iter_alloc.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator> 
+//   basic_string(InputIterator begin, InputIterator end, 
+//   const Allocator& a = Allocator());
+
+#include <string>
+#include <iterator>
+#include <cassert>
+
+#include "../test_allocator.h"
+#include "../input_iterator.h"
+
+template <class It>
+void
+test(It first, It last)
+{
+    typedef typename std::iterator_traits<It>::value_type charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(first, last);
+    assert(s2.__invariants());
+    assert(s2.size() == std::distance(first, last));
+    unsigned i = 0;
+    for (It it = first; it != last; ++it, ++i)
+        assert(s2[i] == *it);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class It>
+void
+test(It first, It last, const test_allocator<typename std::iterator_traits<It>::value_type>& a)
+{
+    typedef typename std::iterator_traits<It>::value_type charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(first, last, a);
+    assert(s2.__invariants());
+    assert(s2.size() == std::distance(first, last));
+    unsigned i = 0;
+    for (It it = first; it != last; ++it, ++i)
+        assert(s2[i] == *it);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    const char* s = "12345678901234567890123456789012345678901234567890";
+
+    test(s, s);
+    test(s, s, A(2));
+
+    test(s, s+1);
+    test(s, s+1, A(2));
+
+    test(s, s+10);
+    test(s, s+10, A(2));
+
+    test(s, s+50);
+    test(s, s+50, A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s), A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+1));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+1), A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A(2));
+}
diff --git a/test/strings/basic.string/string.cons/move.pass.cpp b/test/strings/basic.string/string.cons/move.pass.cpp
new file mode 100644
index 0000000..80887dc
--- /dev/null
+++ b/test/strings/basic.string/string.cons/move.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string<charT,traits,Allocator>&& str);
+
+#include <string>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+#include "../test_allocator.h"
+
+template <class S>
+void
+test(S s0)
+{
+    S s1 = s0;
+    S s2 = std::move(s0);
+    assert(s2.__invariants());
+    assert(s0.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == s1.get_allocator());
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(A(3)));
+    test(S("1", A(5)));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+#endif
+}
diff --git a/test/strings/basic.string/string.cons/move_alloc.pass.cpp b/test/strings/basic.string/string.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..7b45647
--- /dev/null
+++ b/test/strings/basic.string/string.cons/move_alloc.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string&& str, const Allocator& alloc);
+
+#include <string>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+#include "../test_allocator.h"
+
+template <class S>
+void
+test(S s0, const typename S::allocator_type& a)
+{
+    S s1 = s0;
+    S s2(std::move(s0), a);
+    assert(s2.__invariants());
+    assert(s0.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == a);
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(), A(3));
+    test(S("1"), A(5));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+#endif
+}
diff --git a/test/strings/basic.string/string.cons/move_assignment.pass.cpp b/test/strings/basic.string/string.cons/move_assignment.pass.cpp
new file mode 100644
index 0000000..12c02ca
--- /dev/null
+++ b/test/strings/basic.string/string.cons/move_assignment.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& 
+//   operator=(basic_string<charT,traits,Allocator>&& str);
+
+#include <string>
+#include <cassert>
+
+#ifdef _LIBCPP_MOVE
+
+#include "../test_allocator.h"
+
+template <class S>
+void
+test(S s1, S s2)
+{
+    S s0 = s2;
+    s1 = std::move(s2);
+    assert(s1.__invariants());
+    assert(s2.__invariants());
+    assert(s1 == s0);
+    assert(s1.capacity() >= s1.size());
+}
+
+#endif
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+    typedef std::string S;
+    test(S(), S());
+    test(S("1"), S());
+    test(S(), S("1"));
+    test(S("1"), S("2"));
+    test(S("1"), S("2"));
+
+    test(S(),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("123456789"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+#endif
+}
diff --git a/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp
new file mode 100644
index 0000000..517e5f6
--- /dev/null
+++ b/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const charT* s, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+template <class charT>
+void
+test(const charT* s)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    unsigned n = T::length(s);
+    S s2(s);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class charT>
+void
+test(const charT* s, const test_allocator<charT>& a)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    unsigned n = T::length(s);
+    S s2(s, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test("");
+    test("", A(2));
+
+    test("1");
+    test("1", A(2));
+
+    test("1234567980");
+    test("1234567980", A(2));
+
+    test("123456798012345679801234567980123456798012345679801234567980");
+    test("123456798012345679801234567980123456798012345679801234567980", A(2));
+}
diff --git a/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp
new file mode 100644
index 0000000..f0f38bc
--- /dev/null
+++ b/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& 
+//   operator=(const charT* s);
+
+#include <string>
+#include <cassert>
+
+template <class S>
+void
+test(S s1, const typename S::value_type* s2)
+{
+    typedef typename S::traits_type T;
+    s1 = s2;
+    assert(s1.__invariants());
+    assert(s1.size() == T::length(s2));
+    assert(T::compare(s1.data(), s2, s1.size()) == 0);
+    assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+    typedef std::string S;
+    test(S(), "");
+    test(S("1"), "");
+    test(S(), "1");
+    test(S("1"), "2");
+    test(S("1"), "2");
+
+    test(S(),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("123456789"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+}
diff --git a/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
new file mode 100644
index 0000000..83104a1
--- /dev/null
+++ b/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+template <class charT>
+void
+test(const charT* s, unsigned n)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(s, n);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class charT>
+void
+test(const charT* s, unsigned n, const test_allocator<charT>& a)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(s, n, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test("", 0);
+    test("", 0, A(2));
+
+    test("1", 1);
+    test("1", 1, A(2));
+
+    test("1234567980", 10);
+    test("1234567980", 10, A(2));
+
+    test("123456798012345679801234567980123456798012345679801234567980", 60);
+    test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
+}
diff --git a/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp
new file mode 100644
index 0000000..a2e7a53
--- /dev/null
+++ b/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(size_type n, charT c, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+template <class charT>
+void
+test(unsigned n, charT c)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(n, c);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class charT>
+void
+test(unsigned n, charT c, const test_allocator<charT>& a)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(n, c, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class Tp>
+void
+test(Tp n, Tp c)
+{
+    typedef char charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(n, c);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class Tp>
+void
+test(Tp n, Tp c, const test_allocator<char>& a)
+{
+    typedef char charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(n, c, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test(0, 'a');
+    test(0, 'a', A(2));
+
+    test(1, 'a');
+    test(1, 'a', A(2));
+
+    test(10, 'a');
+    test(10, 'a', A(2));
+
+    test(100, 'a');
+    test(100, 'a', A(2));
+
+    test(100, 65);
+    test(100, 65, A(3));
+}
diff --git a/test/strings/basic.string/string.cons/substr.pass.cpp b/test/strings/basic.string/string.cons/substr.pass.cpp
new file mode 100644
index 0000000..8687fa8
--- /dev/null
+++ b/test/strings/basic.string/string.cons/substr.pass.cpp
@@ -0,0 +1,130 @@
+//===----------------------------------------------------------------------===//
+//
+// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string<charT,traits,Allocator>& str, 
+//              size_type pos, size_type n = npos, 
+//              const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+template <class S>
+void
+test(S str, unsigned pos)
+{
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    try
+    {
+        S s2(str, pos);
+        assert(s2.__invariants());
+        assert(pos <= str.size());
+        unsigned rlen = str.size() - pos;
+        assert(s2.size() == rlen);
+        assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+        assert(s2.get_allocator() == A());
+        assert(s2.capacity() >= s2.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+template <class S>
+void
+test(S str, unsigned pos, unsigned n)
+{
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    try
+    {
+        S s2(str, pos, n);
+        assert(s2.__invariants());
+        assert(pos <= str.size());
+        unsigned rlen = std::min(str.size() - pos, n);
+        assert(s2.size() == rlen);
+        assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+        assert(s2.get_allocator() == A());
+        assert(s2.capacity() >= s2.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+template <class S>
+void
+test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
+{
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    try
+    {
+        S s2(str, pos, n, a);
+        assert(s2.__invariants());
+        assert(pos <= str.size());
+        unsigned rlen = std::min(str.size() - pos, n);
+        assert(s2.size() == rlen);
+        assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+        assert(s2.get_allocator() == a);
+        assert(s2.capacity() >= s2.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test(S(A(3)), 0);
+    test(S(A(3)), 1);
+    test(S("1", A(5)), 0);
+    test(S("1", A(5)), 1);
+    test(S("1", A(5)), 2);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 0);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 5);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 500);
+
+    test(S(A(3)), 0, 0);
+    test(S(A(3)), 0, 1);
+    test(S(A(3)), 1, 0);
+    test(S(A(3)), 1, 1);
+    test(S(A(3)), 1, 2);
+    test(S("1", A(5)), 0, 0);
+    test(S("1", A(5)), 0, 1);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100);
+
+    test(S(A(3)), 0, 0, A(4));
+    test(S(A(3)), 0, 1, A(4));
+    test(S(A(3)), 1, 0, A(4));
+    test(S(A(3)), 1, 1, A(4));
+    test(S(A(3)), 1, 2, A(4));
+    test(S("1", A(5)), 0, 0, A(6));
+    test(S("1", A(5)), 0, 1, A(6));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0, A(8));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1, A(8));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));
+}